fallingintoZero
05-02-2006, 04:57 PM
I know this is covered in the FAQ section, but what it says causes the problem isn't occuring. And I checked older messages and none of them resolved this issue.
A fellow CF poster here really helped me out and created a PHP script for me that allows a user to upload a file to my site. When they upload the file, they have an option to select the directory, and depending on which directory they select, it e-mails a different person that is associated with that directory. But we are thrown through a loop tryin got figure out why i am getting this error when i go to test it out:
Warning: move_uploaded_file(): Moved: '/var/tmp/phpgGCU5h' to 'irvineup/upload test - irvine.txt' in /home/variable/public_html/upload/ftp.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at /home/variable/public_html/upload/ftp.php:24) in /home/variable/public_html/upload/ftp.php on line 26
It works great on his server when he tested it... but i can't get it to work on mine for some reason. The folders are CHMOD to 777 like they should be. The file uploads correctly. The correct person is e-mailed. But I can't get rid of that error. I figured i would post in the PHP forum to see if anyone could help me out. Here is the exact code as it is on the site:
<?php
$error = ""; // Set a variable that will be used for errors
$sendTo = ""; // Set a variable that will be used for emailing
if(isset($_POST['upload']) && $_POST['upload'] == 'Upload File') // Form is submitted
{
$whereto = $_POST['where']; // Gets post value from select menu
$whatfile = $_FILES['uploadedfile']['name']; // Gets file value from file upload input
$subject = "File uploaded to ". $whereto ." directory"; // This is the subject that will appear in the email
$from = "FTP UPLOAD <noreply@variableimageprinting.com>";
if(empty($whereto)) // Checks to see if $whereto is empty, if so echo error
{
$error = "You need to choose a directory.<br />";
}
if($whatfile == NULL) // Checks to see if file input field is empty, if so throw an error
{
$error .= "You need to choose a file.";
}
if(!empty($whereto) && $whatfile != NULL) //if no errors so far then continue uploading
{
$target_path = "$whereto/"; // The directory the file will be placed
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename($whatfile);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
header("Location: /about.html"); // Directs user back to page of choice
}
else
{
/* if there was a problem then throw an error */
$error .= "There was an error uploading the file, please try again!";
}
if(empty($error))
{
if($whereto == "irvineup") // Change $sentTo depending on the directory chosen
{
$sendTo = "Irvine <vip@variableimageprinting.com>"; // Change this to an email address of your own
}
if($whereto == "sandiegoup")
{
$sendTo = "San Diego <vipsd@variableimageprinting.com>"; // Change this to an email address of your own
}
/* The below will be what is shown in the email */
$body = "You have received the following from the web based upload form:\r\n";
$body .= "---------------------------------------------------------------\r\n";
$body .= "Subject: File uploaded to ". $whereto ." directory\r\n";
$body .= "File name: ". $whatfile ."\r\n";
$body .= "Upload directory: ". $whereto ."\r\n";
$body .= "Uploader's IP address: ". $_SERVER['REMOTE_ADDR'] ."\r\n";
$body .= "---------------------------------------------------------------\r\n";
/* headers used to show from field in email client */
$headers = 'From: '.$from."\r\n" .
'Reply-To: '.$from;
/* this actually sends the mail */
mail($sendTo, $subject, $body, $headers);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Variable Image Printing</TITLE>
<BODY bgColor=#FECD07 leftMargin=0 background="" topMargin=0 marginheight="0"
marginwidth="0">
<center><div>
<?php
if(!empty($error))
{
echo $error;
}
?>
</div>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<select name="where">
<option value="">Choose a directory</option>
<option value="irvineup">Irvine</option>
<option value="sandiegoup">San Diego</option>
</select>
<input type="submit" name="upload" value="Upload File" />
</form></center></BODY></HTML>
Does anyone see anythign here that could be causing this? Any help would be extremly appreciated. Thanks. :)
A fellow CF poster here really helped me out and created a PHP script for me that allows a user to upload a file to my site. When they upload the file, they have an option to select the directory, and depending on which directory they select, it e-mails a different person that is associated with that directory. But we are thrown through a loop tryin got figure out why i am getting this error when i go to test it out:
Warning: move_uploaded_file(): Moved: '/var/tmp/phpgGCU5h' to 'irvineup/upload test - irvine.txt' in /home/variable/public_html/upload/ftp.php on line 24
Warning: Cannot modify header information - headers already sent by (output started at /home/variable/public_html/upload/ftp.php:24) in /home/variable/public_html/upload/ftp.php on line 26
It works great on his server when he tested it... but i can't get it to work on mine for some reason. The folders are CHMOD to 777 like they should be. The file uploads correctly. The correct person is e-mailed. But I can't get rid of that error. I figured i would post in the PHP forum to see if anyone could help me out. Here is the exact code as it is on the site:
<?php
$error = ""; // Set a variable that will be used for errors
$sendTo = ""; // Set a variable that will be used for emailing
if(isset($_POST['upload']) && $_POST['upload'] == 'Upload File') // Form is submitted
{
$whereto = $_POST['where']; // Gets post value from select menu
$whatfile = $_FILES['uploadedfile']['name']; // Gets file value from file upload input
$subject = "File uploaded to ". $whereto ." directory"; // This is the subject that will appear in the email
$from = "FTP UPLOAD <noreply@variableimageprinting.com>";
if(empty($whereto)) // Checks to see if $whereto is empty, if so echo error
{
$error = "You need to choose a directory.<br />";
}
if($whatfile == NULL) // Checks to see if file input field is empty, if so throw an error
{
$error .= "You need to choose a file.";
}
if(!empty($whereto) && $whatfile != NULL) //if no errors so far then continue uploading
{
$target_path = "$whereto/"; // The directory the file will be placed
/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename($whatfile);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
header("Location: /about.html"); // Directs user back to page of choice
}
else
{
/* if there was a problem then throw an error */
$error .= "There was an error uploading the file, please try again!";
}
if(empty($error))
{
if($whereto == "irvineup") // Change $sentTo depending on the directory chosen
{
$sendTo = "Irvine <vip@variableimageprinting.com>"; // Change this to an email address of your own
}
if($whereto == "sandiegoup")
{
$sendTo = "San Diego <vipsd@variableimageprinting.com>"; // Change this to an email address of your own
}
/* The below will be what is shown in the email */
$body = "You have received the following from the web based upload form:\r\n";
$body .= "---------------------------------------------------------------\r\n";
$body .= "Subject: File uploaded to ". $whereto ." directory\r\n";
$body .= "File name: ". $whatfile ."\r\n";
$body .= "Upload directory: ". $whereto ."\r\n";
$body .= "Uploader's IP address: ". $_SERVER['REMOTE_ADDR'] ."\r\n";
$body .= "---------------------------------------------------------------\r\n";
/* headers used to show from field in email client */
$headers = 'From: '.$from."\r\n" .
'Reply-To: '.$from;
/* this actually sends the mail */
mail($sendTo, $subject, $body, $headers);
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Variable Image Printing</TITLE>
<BODY bgColor=#FECD07 leftMargin=0 background="" topMargin=0 marginheight="0"
marginwidth="0">
<center><div>
<?php
if(!empty($error))
{
echo $error;
}
?>
</div>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<select name="where">
<option value="">Choose a directory</option>
<option value="irvineup">Irvine</option>
<option value="sandiegoup">San Diego</option>
</select>
<input type="submit" name="upload" value="Upload File" />
</form></center></BODY></HTML>
Does anyone see anythign here that could be causing this? Any help would be extremly appreciated. Thanks. :)