andy5898 Posted March 6, 2010 Share Posted March 6, 2010 Hi, I am uploading to my website using the following script <?php // Check for a valid password to prevent unauthorised uploads // Change 'password' to the name of the password field on your form (if there is one) $pass = ''; if (isset($_POST['password'])) $pass = $_POST['password']; // Change 'yourchoice' to the password you will use // If you don't want to use a password, just specify '' if ($pass != '') { die ('Password not recognised'); } // Specify the types of file you want to allow, separated by commas $allowedTypes = array('.jpg','.gif','.bmp','.png','.001','.xls','.doc'); // Specify the maximum file size you will accept $maxsize = 10000000; // Specify the folder that will receive the uploaded files, with trailing backslash $destination = 'myfiles/'; // Replace 'formfile' with the name of the file browser field on your form $upfile = $_FILES['formfile']; if ($upfile['name']<>'') { if (is_uploaded_file($upfile['tmp_name'])) { $filetype = strstr (basename($upfile['name']),'.'); $filetype = strtolower ($filetype); if (!in_array($filetype,$allowedTypes)) { die ("Invalid file format: ".$filetype." ".$upfile['type']); } $filesize = $upfile['size']; if ($filesize > $maxsize) { die ("File size exceeds maximum allowed"); } } else { die ("This is not an uploaded file"); } } else { die ("Please specify a file name"); } $filename = basename($upfile['name']); $copyto = $destination.$filename; move_uploaded_file($upfile['tmp_name'],$copyto) header('Location: http://www.cbmaccounts.co.uk/successful.html/'); exit; ?> It all works fine I can upload etc, but when it has uploaded successfully it won't take me to the page I want it too. Can anyone tell me what Im doing wrong and how I fix it? Cheers Link to comment https://forums.phpfreaks.com/topic/194319-uploading-using-php-then-redircetion-doesnt-work-help/ Share on other sites More sharing options...
PravinS Posted March 6, 2010 Share Posted March 6, 2010 You have given "/" after .html in header("Location: ") Link to comment https://forums.phpfreaks.com/topic/194319-uploading-using-php-then-redircetion-doesnt-work-help/#findComment-1022247 Share on other sites More sharing options...
andy5898 Posted March 6, 2010 Author Share Posted March 6, 2010 Thanks for your help worked a treat. Cheers Link to comment https://forums.phpfreaks.com/topic/194319-uploading-using-php-then-redircetion-doesnt-work-help/#findComment-1022257 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.