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 = "info@xxxxxxxxxxxx.net.nz"; $subject = "A File has been uploaded by " . $var2; $body = ""; $headers = 'From: info@xxxxxxxxxx.net.nz'; 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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(); ?> Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
fooDigi Posted February 23, 2008 Share Posted February 23, 2008 right, without using ob_start(); Quote Link to comment 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.