Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP-Uploader

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28085
    Paradox
    Member

    Hey everyone,

    I have a problem with my PHP-Upload form, that (somehow) doesn’t work.

    upload_file.php

    Code:
    Unknown extension!

    ‘;
    $errors=1;
    }
    else
    {
    //get the size of the image in bytes
    //$_FILES[‘image’][‘tmp_name’] is the temporary filename of the file
    //in which the uploaded file was stored on the server
    $size=filesize($_FILES[‘image’][‘tmp_name’]);

    //compare the size with the maxim size we defined and print error if bigger
    if ($size > MAX_SIZE*1024)
    {
    echo ‘

    You have exceeded the size limit!

    ‘;
    $errors=1;
    }

    //we will give an unique name, for example the time in unix time format
    $image_name=time().’.’.$extension;
    //the new name will be containing the full path where will be stored (images folder)
    $newname=”/images/”.$image_name;
    //we verify if the image has been uploaded, and print error instead
    $copied = copy($_FILES[‘image’][‘tmp_name’], $newname);
    if (!$copied)
    {
    echo ‘

    Copy unsuccessfull!

    ‘;
    $errors=1;
    }}}}

    //If no errors registred, print the success message
    if(isset($_POST[‘Submit’]) && !$errors)
    {
    echo “

    File Uploaded Successfully! Try again!

    “;
    }

    ?>

    Thats my entire code for uploading images on my server. But, the problem:

    I’m getting the following error message: Warning: copy() [function.copy]: Unable to access in /var/www/web1/html/uploader/upload.php on line 58

    I also don’t get… I’ve created the /images folder on my webspace, but it still doesn’t upload.

    Hope someone could help me, I’m not perfect in PHP. > My website: http://knuddels-hosting.de/uploader/upload.php

    #71334
    Paradox
    Member

    This is how it looks in Confixx: http://i50.tinypic.com/34eyh5j.jpg

    #71487
    Paradox
    Member

    Ok, now I’ve changed my entire code, I actually got it from http://www.zymic.com/tutorials/php/creating-a-file-upload-form-with-php/comments/, and here it is:

    upload.php

    Code:
    $max_filesize)
    die(‘The file you attempted to upload is too large.’);

    // Check if we can upload to the specified path, if not DIE and inform the user.
    if(!is_writable($upload_path))
    die(‘You cannot upload to the specified directory, please CHMOD it to 777.’);

    // Upload the file to your specified path.
    if(move_uploaded_file($_FILES[‘userfile’][‘tmp_name’],$upload_path . $filename))
    echo ‘Your file upload was successful, view the file here‘; // It worked.
    else
    echo ‘There was an error during the file upload. Please try again.’; // It failed :(.

    ?>

    index.php

    Code:


    My example website: http://www.knuddels-hosting.de/php/testsite.php

    Following error occurs: "There was an error during the file upload. Please try again."

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.