Jump to content

[SOLVED] Isset not working!!


tommyda

Recommended Posts

Im building an admin panel with an image upload function, but I have set it to only run the image upload script if the file field is set. For some reason the function is running even if it is not set, which is obviously giving me errors.

 

I also created 2 radio buttons one next to an input field named "url" and the other next to the file field named "upload" I tried to change the upload function to only run when radio button "upload" is selected which also doesnt work and runs either way.

 

The form code:

  <tr>
            <td valign="top">Image Url</td>
            <td><label>
             <input type="radio" name="imageupload" value="url"><input name="imageurl" type="text" id="slug" size="70" />
            </label></td>
          </tr>
          <tr>
            <td valign="top">Image Upload</td>
            <td><label>
             <input type="radio" checked name="imageupload" value="upload"> <input name="new_image" type="file" id="new_image" size="60" />
            </label></td>
          </tr>

 

The Upload Function:

<?php 
if ($_POST['imageupload']='upload' && isset($_FILES['new_image'])){
              $imagename = $_FILES['new_image']['name'];
              $source = $_FILES['new_image']['tmp_name'];
              $target = "../images/".$imagename;
              move_uploaded_file($source, $target);

              $imagepath = $imagename;
              $save = "../images/" . $imagepath;
              $file = "../images/" . $imagepath; 

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 120; 

              $diff = $width / $modwidth;

              $modheight = $height / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 

              $save = "../images/sml_" . $imagepath; 
              $file = "../images/" . $imagepath; 

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 80; 

              $diff = $width / $modwidth;

              $modheight = $height / $diff; 
              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 
              $fullimagepath = $baseurl.'/images/'.$imagepath;


          }else
          
          {
          $fullimagepath = $_POST['imageurl'];
          
          };

?>

 

Any help would be much appreciated.

 

Thanks for reading.

Link to comment
https://forums.phpfreaks.com/topic/181543-solved-isset-not-working/
Share on other sites

Archived

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

×
×
  • Create New...

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.