bigkga Posted February 21, 2008 Share Posted February 21, 2008 I am having trouble with my file uploader on a webpage. Whenever I test it out I get the message that there is an error. I have separate uploads directory for the "client" so that person can upload. My uploader.php contains the following <?php require '/home/xxxxxxxxx/Includes/connect.php'; /* Assign variables from form */ $var1 = mysql_real_escape_string($_POST["leadon"]); $var2 = mysql_real_escape_string($_POST["client"]); $target_path = $var1 . $var2 . '/'; /*Create path to upload to*/ /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); echo $target_path; if(move_uploaded_file($_FILES['uploadedfile']['name'], $target_path)) { /*If file successfully moved to directory*/ /* Send Email to us */ $to = "[email protected]"; $subject = "A File has been uploaded by " . $var2; $body = ""; $headers = 'From: [email protected]'; mail($to, $subject, $body, $headers); /* Once complete return to........ */ header("Location: https://xxxxxxxxxxxxxxxxxxxxxxxx/fileuploaded.php"); }else{ echo "There was an error uploading the file, please try again!"; } ?> My .htaccess file contains the following redirect /Clients/bob http://www.xxxxxxxxxxxxx.net.nz redirect /Clients/bob/ http://www.xxxxxxxxxx.net.nz RedirectMatch (.*)\index.php http://www.xxxxxxxxxx.net.nz <Files ~ "\.(in|sql|pdf)$"> order allow,deny deny from all </Files> bob is the client name. What is wrong with this? I think it use to work but not anymore. Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/ Share on other sites More sharing options...
bigkga Posted February 22, 2008 Author Share Posted February 22, 2008 Does anyone know how I can solve this please Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-473369 Share on other sites More sharing options...
schilly Posted February 22, 2008 Share Posted February 22, 2008 I'm pretty sure you want if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) ['name'] is just the filename not where it is temporarily stored. Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-473375 Share on other sites More sharing options...
bigkga Posted February 23, 2008 Author Share Posted February 23, 2008 Hi there Thanks for that answer. I now get this error message which is progress i think ../Uploads/bob/tv.jpg Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxxxx/www/Scripts/uploader.php:13) in /home/xxxxxxxx/www/Scripts/uploader.php on line 24 Line 24 is header("Location: https://sexxxxxx.xxxxxxxx.net.nz/xxxxxxxnetnz/fileuploaded.php"); Any ideas? Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-474284 Share on other sites More sharing options...
mmarif4u Posted February 23, 2008 Share Posted February 23, 2008 put this at top of your page. <?php ob_start(); ?> Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-474312 Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 if you output text (echo $target_path;) before you call header() you will get that error Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-474313 Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 right, without using ob_start(); Link to comment https://forums.phpfreaks.com/topic/92244-file-uploading-problem/#findComment-474315 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.