Hi All,
I've got a form with 2 image fields, form_photo and form_logo, from where users can upload the pictures for their business.
What would be the best way to check if a file has been submited? There won't always be one or the other file to upload, especially for the form_logo field.
This is how I'm currently doing it:
<?php
if ($form_photo){
$data = addslashes(fread(fopen($form_photo, "r"), filesize($form_photo)));
}
if ($form_logo){
$data2 = addslashes(fread(fopen($form_logo, "r"), filesize($form_logo)));
}
//to then insert the data into the table
$sql = "INSERT INTO $table (item_logo,item_logo_filename,item_logo_filesize,item_logo_filetype,item_photo,item_photo_filename,item_photo_filesize,item_photo_filetype) VALUES ('$data2','$form_logo_name','$form_logo_size','$form_logo_type','$data','$form_photo_name','$form_photo_size','$form_photo_type');
$result = mysql_query($sql);
?>
With the above code I get errors when no file has been uploaded, but as I said there won't always be both files.
Any help would be greatly appreciated.
Gill