PHP Upload script help

Looking for some assistance.

I have an PHP upload script that works fine on my current host.

When I moved it to my new host, it doesn’t work.

As far as I can tell, I have made the changes needed for the new host.

Can somebody help?

can you post the code?

The only thing I changed is the upload path.


<?PHP

if ($step == 'doupload')
{
	$internal_error_msg = '';
	$upload_dir = '/www1303/web/protoc/upload';
	$today = date("F j, Y, g:i a");
	if ($f_filename_size < 8000000000)
	{
		#echo "f_filename: $f_filename<BR>
";
		#echo "f_filename_name: $f_filename_name<BR>
";
		#echo "f_filename_size: $f_filename_size<BR>
";
		#echo "f_filename_type: $f_filename_type<BR><BR>
";
		if (copy($f_filename, "$upload_dir/$f_filename_name"))
		{
			echo "$f_filename_name uploaded successfully. ($f_filename_size bytes.)";
			$fp = fopen ("$upload_dir/upload.log", "a+");
			fwrite($fp, "$today - $f_filename_name uploaded successfully. ($f_filename_size bytes.)
");
			fclose($fp);
			$emailaddy = 'doug@protocallonline.com';
			$message = "Hello,

A file has been uploaded:

Filename: $f_filename_name ($f_filename_size bytes)
Download: http://www.protocallonline.com/upload/$f_filename_name

";
			mail($emailaddy, "Uploaded file", $message, "From: [email]null@protocallonline.com[/email]
");
		}
		else
		{
			# An error occurred during your submission.
			$internal_error_msg .= '<DIV class="contentwarning">An error occurred during your upload. Please try 
renaming your file and uploading it again.</DIV>';
		}
	}
	else
	{
		# File too large.
		$internal_error_msg .= '<DIV class="contentwarning">The file is too large.</DIV>';
	}

	unlink($f_filename);

	if ($internal_error_msg != "")
	{
		echo $internal_error_msg;
		echo '<BR>';
	}
}

?>

Here is the info from them on the PHP config for the new sitehttp://161.58.174.10/tech-support-phpinfo.php

current site: http://www.protocallonline.com/tech-support-phpinfo.php

there is no form for the script :confused:

you sure thats the whole script?

something like

<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="imagefile">
<input type="submit" name="Submit" value="Submit">

it is the whole thing

should those be the first three lines?

do you need a email sent or can you lose that bit?

That is the biggest thing I need.

Some of my customers just post files and never let me know.

most likely problem - guessing at you need to CHMOD the ‘upload’ directory to 777.

DT.

already at 777

Where should the form info go?

Why does it work at www.protocallonline.com the way it is, but not at 161.58.174.10

go to the transefers page.

www.protocallonline.com is my current site, the IP address is where it is moving to.

still not right

try it at http://161.58.174.10

go to the contacts / transfers page and try it.

P.S. remind me to send you some teflon tape for all of the help!

right looked at it and its a 2 page script

first index.php

<FORM enctype="multipart/form-data" action="upload.php" method="post">
<INPUT type="hidden" name="step" value="doupload">
<INPUT type="file" name="f_filename" size="20" maxlength="1024"> 
<INPUT type="submit" value="Upload"></FORM>

then upload.php

<?PHP

if ($step == 'doupload')
{
$internal_error_msg = '';
$upload_dir = '/path/to/www/uploadfolder';
$today = date("F j, Y, g:i a");
if ($f_filename_size < 8000000000)
{
#echo "f_filename: $f_filename<BR>
";
#echo "f_filename_name: $f_filename_name<BR>
";
#echo "f_filename_size: $f_filename_size<BR>
";
#echo "f_filename_type: $f_filename_type<BR><BR>
";
if (copy($f_filename, "$upload_dir/$f_filename_name"))
{
echo "$f_filename_name uploaded successfully. ($f_filename_size bytes.)";
$fp = fopen ("$upload_dir/upload.log", "a+");
fwrite($fp, "$today - $f_filename_name uploaded successfully. ($f_filename_size bytes.)
");
fclose($fp);
$emailaddy = 'email@domain.com';
$message = "Hello,

A file has been uploaded:

Filename: $f_filename_name ($f_filename_size bytes)
Download: http://www.domian.com/upload/$f_filename_name

";
mail($emailaddy, "Uploaded file", $message, "From: [email]noone@domain.com/
");
}
else
{
# An error occurred during your submission.
$internal_error_msg .= '<DIV class="contentwarning">An error occurred during your upload. Please try 
renaming your file and uploading it again.</DIV>';
}
}
else
{
# File too large.
$internal_error_msg .= '<DIV class="contentwarning">The file is too large.</DIV>';
}

unlink($f_filename);

if ($internal_error_msg != "")
{
echo $internal_error_msg;
echo '<BR>';
}
}

?>

Leaving my script the way it was, I unREMed the echo lines before the third if.

Here are the results:

f_filename:
f_filename_name: burst-rc5d-uau.exe
f_filename_size: 0
f_filename_type:

An error occurred during your upload. Please try renaming your file and uploading it again.

Ideas?

The code i posted above works :confused:

I have tested it

here and the upload and email works fine.

So I need 2 php pages, Index & upload.

Just change the variable in the upload to fit my site?

I’ll give it a shot.

Ok, here is what happens.

It seems to be uploading the file, then it goes to a blank web page & the file is not in the upload dir.

Ideas?

Thanx!!!

link to the index page? :slight_smile:

OK.

I have some more info on the problem.

I guess by default, when you upload with PHP, it puts the file in the temp directory.

The tmp directory on my host is not writeable.

Need to find a way to get it not to write to the temp directory.

The folder “upload” has to be writable chmod 777 or the script won’t work

The upload folder is at 777

I was told the when you upload in PHP, the file first goes to the tmp directory specified in the php.ini file.

I can not change that.

Need a work around