| ||||||
|
Fileupload Checklist: What to look for when fileupload functions are not working
There are numerous reasons why a HTML file upload forms may fail to work. The most common errors are found in the coding of the HTML form itself. Based on this I will go through a short checklist for you to make sure that all the required elements are present in your HTML form before claiming that your host has done something wrong. Has your HTML Form's enctype been defined? This is one of the most obvious form upload errors and a frequent rookie mistake. An understandable one too, as normal data forms do not require the enctype attribute. Nevertheless, fileupload forms do, so make sure the following attribute is present inside your form tag: <form enctype="multipart/form-data" action="<?php echo $PHP_SELF;?>" method="POST"> If you are uploading multiple file uploads, have you turned file into an array? If you are uploading an array of files, make sure the file input's names are defined as one: File 1: <input name="file[]" type="file"><br> File 2: <input name="file[]" type="file"><br> File 3: <input name="file[]" type="file"><br> PHP Fileupload Variables Make sure you addressing the variables properly. The first box of the array $_FILES should always contain the name provided to the input tags within the HTML. So name="file" = $_FILES["file"]. Next up remember that while a single fileupload's tmp_name will be addressed as follows: $_FILES["file"]["tmp_name"] in a multi file upload it will turn into: $_FILES["file"]["name"][$i] What version of PHP are you working with? If your host uses an older version of PHP it could be that your fileupload variables need to be accessed by alternative definitions, and therefore cannot be accessed via $_FILES. If this is the case to find out how to address your upload variables either check your PHP ini or ask your host. If none of the above listed causes appear to be causing your fileupload problem an email to your host may well be worth while!
|