SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    0 Post(s)
    0 Thread(s)

    help needed in improving functionality of simple file uploading script

    Firstly thanks for the help. This is my very simple file uploader script and i have a few questions about imporvements i would like to make.

    I have included my code so far below for you to look at.

    $target = "upload/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    else {
    echo "Sorry, there was a problem uploading your file.";
    • This script is meant to display the name of file uploaded in the upload successful line but it doesn't it omits it any idea why?
    • I would like to display a web page if the file uploads sucessfully and one if it doesn't what do i add to my script so it will do this?
    • I would like an upload page that automatically displays all the file names in a directory as links to the files.
    • Finally i would like an email sent to me to let me know a file has been uploaded

    My host has said to make this secure and allow only people i want to see the upload area I need to place the upload script in a password protected directory, is this secure enough? I would really appreciate the help or if you could direct me to some kind of tutorial that would help me achieve any of this it's be great.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    0 Post(s)
    0 Thread(s)
    when coding or debugging, you should always turn up error reporting. php will then give you helpful notices.
    PHP Code:
    // put at the very top of your scripts
    you made a typo. it should be obvious once you set it to E_ALL

    to display different pages, just replace your current echo statements with the html to display. alternatively, replace the echo's with another file by using include()

    to get the files in a directory, see scandir(), glob(), or readdir()
    to send an email, see mail()

    and yes, password protecting the directory which holds these files and this script should be sufficient.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts