Jump to content


Photo

Check for the image. if != continue with the resto of the script.


  • Please log in to reply
2 replies to this topic

#1 Julian

Julian
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts

Posted 21 September 2006 - 06:20 PM

Hi guys...

I have this script that checks for an image.  But if the image is there I want the script to continue with the rest keeping the image already uploaded.  Can anyboy help me with this....  Here's code:

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")){

      $file_type = $_FILES['imgfile']['type'];
      $file_name = $_FILES['imgfile']['name'];
      $file_size = $_FILES['imgfile']['size'];
      $file_tmp = $_FILES['imgfile']['tmp_name'];

      if(!is_uploaded_file($file_tmp)){
      exit(); //I don't want to exit but continue with the rest of the scrip just don't execute what's related to the image.
      }
      $getExt = explode ('.', $file_name);
      $file_ext = $getExt[count($getExt)-1];
      bla,bla,bla..... etc.......

  I want the script continues here:
    $insertSQL = sprintf("UPDATE.......

Really appreciated your help..... Alaways the best.

#2 paul2463

paul2463
  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 21 September 2006 - 06:27 PM

if you do not want to carry out any action if the "if" statement is true the put nothing there i.e

if ( the file is uploaded) {

} else {
do something
}

or a better way to do it is to reverse the if statement so you only carry out something if it is true i.e

if ( the file is not uploaded) {
do this
}


you do not need an else statement at all then and it will carry on with the rest of the code.

hope that helps

you cannot affect the past but you can ruin a perfectly good present by worrying about the future

*********************************************************************
The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

#3 Julian

Julian
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts

Posted 21 September 2006 - 06:39 PM

Worked just fine... Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users