Jump to content

pdf not uploading


pagegen

Recommended Posts

Hi guys

 

I am using the code below to upload files, image files seem to upload ok, but for some reason I cnt seem to upload pdf files.. any suggestions?

 

 

Thank you

 

<?php
ini_set('file_uploads','on'); 
ini_set('upload_max_filesize','1000M'); 
ini_set('max_execution_time', 0);



    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("invoices/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"], "invoices/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      }


?>  


<form action="" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

Link to comment
Share on other sites

Your code has no error checking/error reporting logic in it to get it to tell you if the upload worked or failed or why it is failing.

 

You must test if $_FILES array contains anything and then you must test the $_FILES["file"]["error"] element before you attempt to access any of the uploaded file information. You are probably exceeding one of the size limits.

 

Ref: http://in2.php.net/manual/en/ini.core.php#ini.post-max-size

      http://in2.php.net/manual/en/features.file-upload.errors.php

 

Also, you cannot set file_uploads or upload_max_filesize in your script. They must be set before your script executes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.