0

Failed to upload file using HTML form:

after I click the submit botton, I could print out the $_FILES["file"]["name"] and $_FILES["file"]["type"] and ["size"] and ["tmp_name"] and ["error"] and etc.but I could not find the file in the tmp folder(it should be there by default)!I don't know why.

the html code goes like this:

<form action="manage.php?act=getback.questionOpt" target="fileUp" method="post" id="f1" enctype="multipart/form-data">
   <p id="file_u">
      <input type="file" name="file">
        <iframe width="0px" height="0px" name="fileUp" style="display:none">
        </iframe>
   </p>
</form>
6
  • Checkout the complete temp-file like echo $_FILES["file"]["tmp_name"];? Commented Sep 5, 2012 at 6:58
  • When you said you couldnt find the file, did you check the tmp_name'd file or look for the original filename? It may also be its not set to go to /tmp but maybe /var/tmp or other, if its a windows server it maybe the file was seen as a virus and the anti virus has removed it - did you use code to check it was there or did you just look yourself? Commented Sep 5, 2012 at 7:03
  • This issue may be occurred due to folder permission... Commented Sep 5, 2012 at 7:08
  • Refer this link for more details.... [Click Here][1] [1]: stackoverflow.com/questions/1819563/… Commented Sep 5, 2012 at 7:09
  • 1
    can you show your php code too?? Commented Sep 5, 2012 at 7:16

2 Answers 2

1

Uploaded files are deleted from the temp-directory unless they are moved or renamed!

There is a small note about that just above the third example on the PHP-Documentation at https://www.php.net/manual/en/features.file-upload.post-method.php

Therefore you will not be able to see the file after the request is finished.

Simply renaming the file should do the trick.

Sign up to request clarification or add additional context in comments.

Comments

0

How big is your file? If it is too big and exceeds your server limit, it won't upload. If your server has uploading disabled by default, you will need to turn it on in php.ini. This is how:

Open the php.ini file in your editor.

Search for the text string file_uploads. You will find something which says file_uploads = Off | On. If it says Off as the value, problem solved. Otherwise, it could be commented (check for semicolon at start of line). Otherwise:

Change the file permissions of your tmp folder.

Unless you show us the full code, there is nothing else I can do to help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.