SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    upload of PDF via HTML form fails

    Hello,

    I am not able to upload PDF files. The server, IIS6, PHP 5.x throws an error of 2 when I try to upload PDF files.

    The thing is, the PDF file is well within the size limit that I have set both within maxfilesize and my php.ini. I can upload all other types of files without a problem but PDF's get rejected.

    I have not been able to find info on this so I am hoping someone has ran into the issue before.

    I am including the code, I am using common code to eliminate extraneous code errors. Insights would be much appreciated as to why I cannot upload PDFs.

    FORM CODE
    Code HTML4Strict:
    <form enctype="multipart/form-data" action="uploader.php" method="POST" name="upload">
    <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>

    PHP PROCESSING SCRIPT
    PHP Code:
    echo "<pre>";
    print_r($_FILES);
    echo 
    "</pre>";
    // Where the file is going to be placed 
    $target_path "resume/";

    /* Add the original filename to our target path.  
    Result is "resumes/filename.extension" */
    $target_path $target_path basename$_FILES['uploadedfile']['name']);

    if (
    $_FILES["uploadedfile"]["error"] > 0)
      {
      echo 
    "Error: " $_FILES["uploadedfile"]["error"] . "<br />";
      echo 
    "There was an error uploading the file, please try again!";
      }
    else
      {
      echo 
    "Upload: " $_FILES["uploadedfile"]["name"] . "<br />";
      echo 
    "Type: " $_FILES["uploadedfile"]["type"] . "<br />";
      echo 
    "Size: " . ($_FILES["uploadedfile"]["size"] / 1024) . " Kb<br />";
      echo 
    "Stored in: " $_FILES["uploadedfile"]["tmp_name"];
        
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
        echo 
    "The file ".  basename$_FILES['uploadedfile']['name']). 
        
    " has been uploaded";

    Thank you

  2. #2
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure you need to use the basename function....I believe this is handled for you...this is tricky though! Code looks correct...

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I restarted my server and PDF uploads worked. Crazy IIS6.


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
  •