rawky1976 Posted February 7, 2007 Share Posted February 7, 2007 Hello The following upload script uploads the file to the server as expected but always re-directs to the upload failure page??? Something wrong with my if statement??? <?php if(isset($_POST['buttonSubmit'])) { $uploadpath = "uploads/"; $uploadpath = $uploadpath . basename( $_FILES['uploadFile']['name']); if(move_uploaded_file($_FILES['uploadFile']['tmp_name'], $uploadpath)) { echo"This file: ". basename( $_FILES['uploadFile']['name']). "has been uploaded Other Details:"; echo"Mime Type: ". $_FILES['uploadFile']['type'] .""; echo"Size (Bytes): ". $_FILES['uploadFile']['size'] .""; echo"File Name: ". $_FILES['uploadFile']['name'] .""; } else { echo "There was an error uploading the file, please try again!"; } define("no_error", "uploadSuccess.php"); define("yes_error", "uploadError.php"); if(empty($errStr)){ if(@copy($_tmp_name_,uploadpath . "/" . $_name_)){ header("Location: " . no_error); } else { header("Location: " . yes_error); } } else { header("Location: " . yes_error); } } ?> Link to comment https://forums.phpfreaks.com/topic/37535-uploading-weirdness/ Share on other sites More sharing options...
papaface Posted February 7, 2007 Share Posted February 7, 2007 Im pretty sure you have to specify the name of the file: if(move_uploaded_file($_FILES['uploadFile']['tmp_name'], $uploadpath)) { should be: if(move_uploaded_file($_FILES['uploadFile']['tmp_name'], $uploadpath . $_FILES['uploadFile']['name'])) { Link to comment https://forums.phpfreaks.com/topic/37535-uploading-weirdness/#findComment-179445 Share on other sites More sharing options...
rawky1976 Posted February 7, 2007 Author Share Posted February 7, 2007 Sorry man That didn't seem to make any difference! I'm patching two script together so assume I've just mis-crossed some variables somewhere? Mark Link to comment https://forums.phpfreaks.com/topic/37535-uploading-weirdness/#findComment-179451 Share on other sites More sharing options...
rawky1976 Posted February 7, 2007 Author Share Posted February 7, 2007 If I comment out: - define("no_error", "uploadSuccess.php"); define("yes_error", "uploadError.php"); if(empty($errStr)){ if(@copy($_tmp_name_,uploadpath . "/" . $_name_)){ header("Location: " . no_error); } else { header("Location: " . yes_error); } } else { header("Location: " . yes_error); } } Then I get the success message on the original page, and the file uploads. Definitely something in this if statement!? Link to comment https://forums.phpfreaks.com/topic/37535-uploading-weirdness/#findComment-179457 Share on other sites More sharing options...
rawky1976 Posted February 7, 2007 Author Share Posted February 7, 2007 where does errStr come in? Have I defined it anywhere? Link to comment https://forums.phpfreaks.com/topic/37535-uploading-weirdness/#findComment-179460 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.