SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using PHP upload, avoid the writing of a temporary file,or change the tmp folder?

    Hey guys, I am trying to write a script that will let me upload a file selected from a directory on my computer using PHP. I want to browse my PC and select a file which I can do, but when I select upload I get this error:

    PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0

    I think it may because I cannot create a temporary file on my server or my temp folder location is not the default? I looked at phpinfo on my server, which is a university server, and i saw that upload_tmp_dir was F:\Temp

    Can I set my uploads to find this folder? I have a created a folder called uploaded which is where the final file needs to go, but I just cant get it to work. Any suggestions?

    Here is my form:


    Code:
    <form enctype="multipart/form-data" action="ul.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>




    And here is the action script:


    Code:
    <?php// Where the file is going to be placed 
    $target_path = "uploaded/";
    
    $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!";
    }
    ?>
    Thanks!

  2. #2
    SitePoint Zealot mike.fro's Avatar
    Join Date
    Jun 2005
    Location
    Lewisville, Texas
    Posts
    133
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Is the directory writeable/readable?
    Michael John Froseth

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there, i do not know how I can tell if it is read/writable, can I tell from the phpinfo file?

    Thanks

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,301
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by deucalion0 View Post
    i do not know how I can tell if it is read/writable, can I tell from the phpinfo file?
    In your FTP client or online file manager etc, you usually can right click on the directory to see the permissions set on it. It is expressed as three numbers, such as 646, 666, 777 etc.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I do not have access to that folder, I have sent an email to my admin, hopefully they can amend this issue so I can create my application. I appreciate your help with this.



    Thanks


Bookmarks

Posting Permissions

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