Link to home
Start Free TrialLog in
Avatar of ATLien
ATLien

asked on

check to see if a form feild is empty.

Ok I am creatying a script and in this script I allow for users to upload multiple pictures. Here is the script I have so far.

# DEALING WITH PIC_UPLOADS Part 1
if($HTTP_POST_FILES['picture2']){
     $picture2 = $HTTP_POST_FILES['picture2']['tmp_name'];
     $pic5 = getimagesize($picture2) or die("gis_failed");
     $ext = pic_allowed( $pic5[2] ) or list($submit_err_msg, $act) = array("pic_format_not_allowed", "signup");
     $ext = "." . strtolower($ext);
}else{
     $picture2 = $HTTP_POST_VARS['picture2'];
     $pic5 = getimagesize($picture2);
}
     
if($pic5){
       $pic2_width=$pic5[0]; $pic2_height=$pic5[1];
     }else{
       $submit_err_msg="pic_not_found"; $act="signup";
     }    
# DEALING WITH PIC_UPLOADS Part 2
if($HTTP_POST_FILES['picture2']){
     #GENERATING A UNIQUE FILENAME BASED ON THE TIME AND REMOTE IP - AND IF THAT ISN'T UNIQUE I DON'T KNOW WHAT IS
     $filename = "uploads/" . preg_replace("#\W#", "", $HTTP_POST_VARS['user']) ."-". md5(microtime() . $HTTP_SERVER_VARS['REMOTE_ADDR']) . $ext;
     copy($HTTP_POST_FILES['picture2']['tmp_name'], $root_path . $filename);
     @chmod($root_path . $filename, 0755);
     $picture2 = $filename; #For the database
}

I wanted make it where it will only get the image size if there is infact a image selected in the picture2 feild of the forum. See what I am getting is a error that says it can't get image size if I have not selected to upload a second picture. How can I make it to where the script above will only process if there is in fact a picture selected to upload. If there is no picture selected to upload then it will nt attempt to process this portion of the script.
ASKER CERTIFIED SOLUTION
Avatar of aishcash
aishcash
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Giovanni G
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

> Accept comment from aishcash

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

ThG
EE Cleanup Volunteer