Squeebee
asked on
Issue with file uploads
Hi all;
I am trying to add a file submission aspect to a submission form, but I cannot get uploads to confirm they are uploaded:
---------------FORM------- ---------- ------
<input type="hidden" name="MAX_FILE_SIZE" value="2048">
<input name="File" type="file" size="50">
----------------/FORM----- ---------- -------
---------------CODE------- ---------- -------
if (isset($_FILES['File']['na me']))
{
echo("File Uploaded\n");
print_r($_FILES['File']);
}
else
{
echo("no File Uploaded\n");
print_r($_FILES);
}
---------------/CODE------ ---------- ---------- -
-------------OUTPUT------- ---------- ----------
no File Uploaded
Array ( )
--------------/OUTPUT----- ---------- ---------
Now I am new to file uploading, so maybe I am checking the wrong thing.
PHP is 4.2.2 on Apache 2, I will also need to check that the file is a zip file, not interested in uploads of anything else and will want to reject non-zip uploads.
Thanks all, big points cause I want a quick answer.
I am trying to add a file submission aspect to a submission form, but I cannot get uploads to confirm they are uploaded:
---------------FORM-------
<input type="hidden" name="MAX_FILE_SIZE" value="2048">
<input name="File" type="file" size="50">
----------------/FORM-----
---------------CODE-------
if (isset($_FILES['File']['na
{
echo("File Uploaded\n");
print_r($_FILES['File']);
}
else
{
echo("no File Uploaded\n");
print_r($_FILES);
}
---------------/CODE------
-------------OUTPUT-------
no File Uploaded
Array ( )
--------------/OUTPUT-----
Now I am new to file uploading, so maybe I am checking the wrong thing.
PHP is 4.2.2 on Apache 2, I will also need to check that the file is a zip file, not interested in uploads of anything else and will want to reject non-zip uploads.
Thanks all, big points cause I want a quick answer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmm, any way to avoid an extension spoof there? Ie can we check for a zip file by a method other then trusting the extension?
of course you can.
it's call "using magic numbers" (in clear, analysing the header of the binary file, like "PDF", "JPG" etc to deduce the real datafile type)
it's call "using magic numbers" (in clear, analysing the header of the binary file, like "PDF", "JPG" etc to deduce the real datafile type)
and I think you should RTFM about "uploading files" in the PHP online manual
ASKER
I actually will just go with the extension check for now, as I have to approve posts anyway. Thanks for your help Fendrin and Red.
No Problem, I like to help. Thanks for the A! btw, for type checking, try $FILES['file']['type'] to get the mime type.
btw, all of my answers are right in the manual: http://www.php.net/features.file-upload
btw, all of my answers are right in the manual: http://www.php.net/features.file-upload
ASKER