tommyda Posted November 14, 2009 Share Posted November 14, 2009 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 More sharing options...
tommyda Posted November 14, 2009 Author Share Posted November 14, 2009 Its ok, Ive got it if ($_POST['imageupload']=='upload' && isset($_FILES['new_image'])){..... Link to comment https://forums.phpfreaks.com/topic/181543-solved-isset-not-working/#findComment-957605 Share on other sites More sharing options...
rarebit Posted November 14, 2009 Share Posted November 14, 2009 Not fully looked into it, but: if ($_POST['imageupload']=='upload' && isset($_FILES['new_image'])){ Do you notice the difference? Link to comment https://forums.phpfreaks.com/topic/181543-solved-isset-not-working/#findComment-957606 Share on other sites More sharing options...
tommyda Posted November 14, 2009 Author Share Posted November 14, 2009 Thanks rarebit, but I beat you to it. Link to comment https://forums.phpfreaks.com/topic/181543-solved-isset-not-working/#findComment-957608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.