1. This forum is in read-only mode.

PHP upload script

Discussion in 'Non-Emulation Help' started by yoshi2889, May 24, 2010.

  1. yoshi2889

    yoshi2889 Well-Known Member

    I'm a n00b to PHP and this is my first try so...

    I want to create a PHP upload script, using this tutorial.

    I've got two files: upload.html and uploader.php.
    Now, I've tried to upload a file of 100 KB to my server.
    It only gives the error message "There was an error uploading the file, please try again".

    Page: http://yoshi2889creations.vacau.com/upload.html
    and http://yoshi2889creations.vacau.com/uploader.php

    Host: 000webhost (http://www.000webhost.com/)

    upload.html:
    Code:
    <html><head><title>Yoshi2889's Creations: Submit Project</title></head><body>
    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="500" />
    Choose a file to upload: <input name="uploadedfile" type="file" />
    
    <input type="submit" value="Upload File" />
    </form>
    uploader.php:
    Code:
    <?php
    $target_path = "NEW/";
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again.";
    }
    ?>
    Anyone know how to fix this or know a better script?
     
  2. Loonylion

    Loonylion Administrator Staff Member

    your host may not allow php file uploads.
     
  3. yoshi2889

    yoshi2889 Well-Known Member

    Could also be a problem...although I have uploaded a few files with SMF and they work fine.

    Directory is CHModded to 777, FYI.