php upload file on Edit form, prevent UPDATE if no file -


i have form edit existing values in mysql table. 1 of fields stores filename of image, (another stores folder location of image) file has upload field upload image , replace image name in original image name field.

this works fine if choose file, replace existing image. if don't choose replace image, field update empty data.

basically trying update sql query if there image chosen , uploaded.

i using code:

if(!empty($_files['file_slick'])) { $slick = $_files['file_slick']['name']; copy($_files['file_slick']['tmp_name'],'../images/product/'.$folder.'/'.$slick);  $sql_slick = "update tbl_product set prod_slick = '".$slick."' prod_id = '".$prodid."'"; mysql_query($sql_slick); } 

i have tried if(!empty($_post['file_slick'])) neither works. if file chosen , uploaded, moved correct folder , image filename updated field. if image not chosen, empty data updated image filename field.

i have looked around internet (and here) , can see, check prevent empty data should work.

can see wrong here?

try if(!empty($_files['file_slick']['name']))


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -