Leonardo
Leonardo

Reputation: 131

fail in uploading file using html form

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>

Upvotes: 0

Views: 690

Answers (2)

heiglandreas
heiglandreas

Reputation: 3861

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.

Upvotes: 1

Zerium
Zerium

Reputation: 17333

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.

Upvotes: 0

Related Questions