ChaosKnight Posted May 28, 2010 Share Posted May 28, 2010 Yesterday I had a lot of drama with creating a file uploader, but it finally works... Now I had to make alternatives to the file upload, because every hotel has a lot of properties and I don't want to have a hundred or so files of the same image, so I inserted this in the form: <input type="text" id="logoExists" name="logoExists" /> And this PHP code to handle the extra field: if(isset($_POST['submit'])){ $logoExists = $_POST['logoExists']; $allowedExtensions = array("png","jpg","jpeg","gif"); if(($logoExists = '')||($logoExists = null)){ if((isset($_FILES['logo']))&&($_FILES['logo']['tmp_name'] > '')){ if(!in_array(end(explode(".",strtolower($_FILES['logo']['name']))),$allowedExtensions)){ die($_FILES['logo']['name'].' has an invalid file type...<br/>'); }else{ $target_path = "images/logos/"; $target_path = $target_path . basename($_FILES['logo']['name']); if(move_uploaded_file($_FILES['logo']['tmp_name'], $target_path)){ echo "<h3>{$_FILES['logo']['name']} uploaded successfully...</h3><br />"; $logo = $_FILES['logo']['name']; }else{ echo "<h3>{$_FILES['logo']['name']} could not be uploaded...</h3><br />"; } } } }else{ $logo = $logoExists; } But it seems like when I leave out the file and insert the text into the logoExists field, that PHP simply ignores all that PHP code... Can anyone see my mistake?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/203179-upload-script/ Share on other sites More sharing options...
phpchamps Posted May 28, 2010 Share Posted May 28, 2010 if(($logoExists = '')||($logoExists = null)){ use == instead of = you are using assignment operator not comparison operator Quote Link to comment https://forums.phpfreaks.com/topic/203179-upload-script/#findComment-1064540 Share on other sites More sharing options...
ChaosKnight Posted May 28, 2010 Author Share Posted May 28, 2010 Thanks mate!! You have an eagle's eye lol ... SOLVED! Quote Link to comment https://forums.phpfreaks.com/topic/203179-upload-script/#findComment-1064551 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.