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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -