Page 1 of 1
Mime type of blank form submission
Posted: Fri Jul 21, 2006 9:10 am
by croniccoder
Does anyone know what the mime type would be of a form that was submitted with a blank field? I am allowing users to upload files to my server using <input type="file/>.
There are some other input fields which users also fill out. I want to allow them to submit even if the "upload" form is blank, but I am limiting uploads to word or text files.
Posted: Fri Jul 21, 2006 9:14 am
by feyd
Why not test it and find out?
Posted: Fri Jul 21, 2006 9:19 am
by croniccoder
I did. I am using an echo to try and print the mime type:
Code: Select all
$fileatt_type = $_FILES['uploadedFile']['type'];
echo $fileatt_type;
But it is blank. I don't know if that means it's NULL or an empty string or what?
Posted: Fri Jul 21, 2006 9:20 am
by feyd
var_dump() or
var_export() may be of interest then.
Posted: Fri Jul 21, 2006 9:43 am
by croniccoder
var_dump returns string(0)
Posted: Fri Jul 21, 2006 9:50 am
by croniccoder
I want to allow a person to upload a file. The file must be either a word document, or a plain text file. But I also want to allow the form processing to proceed even if the upload form is blank.
Code: Select all
$fileatt_type = $_FILES['uploadedFile']['type'];
$fileatt_name = $_FILES['uploadedFile']['name'];
if (!$fileatt_type == "application/msword" || !$fileatt_type == "text/plain" || $fileatt_name == " ")
{
But I can't figure out what the correct parameter for $fileatt_name or $fileatt_type would be if the form was blank for the upload?
Posted: Fri Jul 21, 2006 10:43 am
by onion2k
string(0) is an empty string .. not a space. Your last assertion should be $fileatt_name == "".