Jump to content

Archived

This topic is now archived and is closed to further replies.

smith.james0

if empty?

Recommended Posts

If need to do an if empty do this for a file upload.
Normally I use this

if ( ! 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

Share this post


Link to post
Share on other sites
I suppose you can try:

[code]$thisvar = $a_row->performance;

if($thisvar == ''){echo"You can't upload air, b*tch.";}[/code]

Share this post


Link to post
Share on other sites
[code]$img = $_POST['image'];

if($img == ''){echo"You didn't specify an image, you dirty wh*re";}[/code]

Share this post


Link to post
Share on other sites
Also:

[code]if(!isset($image)){echo"The variable is empty!";}[/code]

Hope that was of some use. :-)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[code]<?php
// if an image is uploaded
if(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'

Share this post


Link to post
Share on other sites
[code]<?php
// if an image is uploaded
if(isset($_POST['submit'])) {

  if ($_FILES['image1']['size'] > 0) {
    do something...
  }

}
?>[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.