PHP MYSQL OPTIONAL MULTIPLE IMAGE UPLOAD -
i have html form image (multiple images) upload optional
<form action="upload.php" method="post" enctype="multipart/form-data"> <label>name:</label><input type="text" name="name"/></br> <label>brief:</label><input type="text" name="brf"/></br> <label>result:</label><input type="text" name="res"/></br> <label>photographs:</label><input type="file" name="file[]" accept="image" multiple="multiple" /></br> <input type="submit" name="submit" value="add"/></br> </form> i have image upload function working fine images , fails without images. tried split function
if (empty($_files['files']['tmp_name'])) { //my text function } else { //my images function } but no matter do, not call texonly() function
i've tried
if (empty($_files['files']['tmp_name'][$i])) if (($_files['files']['tmp_name'] =="")) if (empty($_files['files'.$i]['tmp_name'])) if (empty($_files['files']['size'])) if (($_files['files']['size'] == 0)) equels not equels is_uploaded_file ..etc..etc but nothing works me...any life saving
print_r($_files) output
with file
array ( [files] => array ( [name] => array ( [0] => penguins.jpg ) [type] => array ( [0] => image/jpeg ) [tmp_name] => array ( [0] => c:\wamp\tmp\php94cf.tmp ) [error] => array ( [0] => 0 ) [size] => array ( [0] => 777835 ) ) ) without file
array ( [files] => array ( [name] => array ( [0] => ) [type] => array ( [0] => ) [tmp_name] => array ( [0] => ) [error] => array ( [0] => 4 ) [size] => array ( [0] => 0 ) ) )
your file tag name file
<label>photographs:</label><input type="file" name="file[]" accept="image" multiple="multiple" /></br> so check file not files
if (empty($_files['file']['tmp_name'])) { //my text function } else { //my images function }
Comments
Post a Comment