Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2017
    Thanked 0 Times in 0 Posts

    File not uploading

    I have two form where a file is uploaded. I have
    <input type="file" name="NameOfFile">
    for both. File uploads in one form but not the other. I am checking all fields before submission
    PHP Code:
    "No file";

    When I submit my second form it prints No file. Has anyone ever had this issue with input type file?

  2. #2
    Regular Coder Vege's Avatar
    Join Date
    Jan 2008
    Thanked 134 Times in 133 Posts
    Check that <form> tags have enctype="multipart/form-data" attribute.

  3. #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Denver, Colorado USA
    Thanked 556 Times in 541 Posts
    The following is a brief list of things that could cause an index in the $_FILES array to not be set -

    1) The total size of the posted data exceeds the post_max_size setting. Both the $_POST and $_FILES arrays will be empty for this case.

    2) Any number of errors in the form page. Just some of the possibilities - any number of typo or capitalization mistakes, nested forms, missing enctype attribute in the form tag, broken markup causing later markup to be ignored, ...

    3) Uploads are not enabled on the server (for all we know, you are using these forms on different servers.)

    4) Code is un-setting all or part of the $_FILES array.

    For item #1, is your form processing code detecting that a post method form was submitted, then detecting if the $_FILES array is empty (and setting up an error message) or not empty before referencing any of the elements in the $_FILES array?

    For item #2, we would need to know the entire markup of the page the form is on to be able to help.

    For item #3, you would need to indicate if both the working and non-working form and form processing code is being executed on the same server.

    For item #4, we would need to know all the relevant php code that gets executed up to the point where the isset() test is at.
    Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts