0

i searched again and again but could not find the right answer. here is the situation. i got more than one forms in the same php file and below shows the code.

when i echo as below

echo count($_FILES["fileUploadPath"] );

it shows 0 as the count and

Notice: Undefined index: addProjectFileUploadPath in C:\wamp...

updated: probelm solved..... error came due to 3rd party jquery plugin called "fileinput"

2
  • What is displayed if you do a var_dump ($_FILES)? Commented Mar 12, 2011 at 4:57
  • Another little thing, if you leave out the action from the form tag it will use the current file. Commented Mar 12, 2011 at 4:58

4 Answers 4

10

add enctype="multipart/form-data" to the form

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

2 Comments

I have enctype="multipart/form-data" already in my form and it still gives the error ?
Unbelievable! This is the only thing (after trying many, many other fixes) that worked!
2

Try looking at the entire array with this:

echo "<pre>".print_r($_FILES,true)."</pre>";

Then use this manual page to let you know what the error numbers mean. That will probably give you a good idea of what is going on.

PHP File Upload Error Codes

3 Comments

it shows "Notice: Undefined index: addProjectFileUploadPath in C:\wamp\www\online_project_skills_development\formAddProjectFiles.php on line 30 0 Array ( ) " and this is say the name i used for file input is undefined. i cannot figure out the reason for that ...
Try adding this in the form: <input type="hidden" name="MAX_FILE_SIZE" value="10485760">
In my case the file size is not the problem. The same file is getting uploaded from another input field only particular input field is creating problem. Any guesses please ?
2

Okay, there are a couple of things you need to be aware of.

1) You can have as many forms on a page as you want, but you can only submit one of them. You need to make sure the form you expect is being submitted. I'm assuming you're using the submit button names for doing this. However this can result in problems if someone submits the form by hitting enter in a text entry region, the button won't be submitted. A hidden field would be better as it would always be submitted.

2) There doesn't seem to be a MAX_FELE_SIZE form input anywhere in your file upload form. File uploading will not work without it. You need to put something like <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> before the file inputs on your form.

Comments

2

I had the same problem before and I noticed that It happens when I don't close the tags, so try closing all input tags like this:

<form action='upload.php' method="post" enctype="multipart/form-data">
<!-- at the end of the input add / -->
<input type='file' name='file'  />
<input type='submit' name='upload' />
</form>

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.