smith.james0 Posted February 24, 2006 Share Posted February 24, 2006 If need to do an if empty do this for a file upload.Normally I use thisif ( ! empty( $a_row->performance ) ) {bla bla bla}but it doesn't work, do you have to do it a different way because it a file upload?Thanks James Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/ Share on other sites More sharing options...
Caesar Posted February 24, 2006 Share Posted February 24, 2006 I suppose you can try:[code]$thisvar = $a_row->performance;if($thisvar == ''){echo"You can't upload air, b*tch.";}[/code] Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12377 Share on other sites More sharing options...
smith.james0 Posted February 24, 2006 Author Share Posted February 24, 2006 Sorry it's <input type="file" name="image" /><br>This doesn't workif ( ! empty( image ) ) { Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12381 Share on other sites More sharing options...
Caesar Posted February 24, 2006 Share Posted February 24, 2006 [code]$img = $_POST['image'];if($img == ''){echo"You didn't specify an image, you dirty wh*re";}[/code] Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12383 Share on other sites More sharing options...
Caesar Posted February 24, 2006 Share Posted February 24, 2006 Also:[code]if(!isset($image)){echo"The variable is empty!";}[/code]Hope that was of some use. :-) Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12387 Share on other sites More sharing options...
smith.james0 Posted February 24, 2006 Author Share Posted February 24, 2006 Thanks for the quick responce. I have just tried both of the and they don't work, i get the message all time. Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12388 Share on other sites More sharing options...
Caesar Posted February 24, 2006 Share Posted February 24, 2006 They should both work fine. Can you post an examplpe of how you are using the code? Are you "POST"ing the variables from an html form on another page? Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12390 Share on other sites More sharing options...
smith.james0 Posted February 25, 2006 Author Share Posted February 25, 2006 [code]<?php// if an image is uploadedif(isset($_POST['submit'])){I put the code here}else{ echo ' <form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data"> <input type="file" name="image" /><br> <input type="file" name="image1" /><br> <input type="submit" name="submit" value="upload and resize image" /> </form>';}?>[/code]I need it to check if there is anything in 'image1' Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12465 Share on other sites More sharing options...
hitman6003 Posted February 25, 2006 Share Posted February 25, 2006 [code]<?php// if an image is uploadedif(isset($_POST['submit'])) { if ($_FILES['image1']['size'] > 0) { do something... }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12466 Share on other sites More sharing options...
smith.james0 Posted February 26, 2006 Author Share Posted February 26, 2006 That works great thanks!!!!!!!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-12549 Share on other sites More sharing options...
xcoderx Posted November 8, 2008 Share Posted November 8, 2008 make sure unwanted files don't get uploaded to your server through this form so make sure to add some blacklist files to be blocked Link to comment https://forums.phpfreaks.com/topic/3574-if-empty/#findComment-685190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.