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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.