Forum Moderators: coopster

Message Too Old, No Replies

PHP Newby needs help with upload page

PHP 4.2 on IIS system, global variables are off

         

scratch

9:56 pm on Sep 23, 2002 (gmt 0)

10+ Year Member


been trying to get this to work all day. I'm doing an upload page on our site and have run into a sticking point when I try to put two strings together. I think a lot of it has come from working with register globals set to off out of a book where it is set to on. Is it possible to get this to work with them set to off

Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwroot\easyftp\sendfiles.php on line 24

line 24 is $savefile = 'C:\maxdata\FTPAdmin\SendFilesHere\UploadForm\'.trim($HTTP_POST_FILES['userfile']['name']);

I am going back and forth a lot on this. The previous lines have all have semi-colons and the basics of PHP seem to be there.

Here is the complete form handler
<?php
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
{
//$filename0 = $HTTP_POST_FILES['userfile']['tmp_name'];
//echo "<br>$filename0 was uploaded successfuly";
echo $HTTP_POST_FILES['userfile']['tmp_name']." is temp name<BR>";
echo $HTTP_POST_FILES['userfile']['name']." is real name<BR>";
$realname = trim($HTTP_POST_FILES['userfile']['name']);
//echo "<br>realname is $realname0 for order";
//echo "<br>copying file to uploads dir";
$upfile = $HTTP_POST_FILES['userfile']['tmp_name'];
$savefile = 'C:\maxdata\FTPAdmin\SendFilesHere\UploadForm\'.trim($HTTP_POST_FILES['userfile']['name']);
IF (!copy($upfile,$savefile))
{
echo trim('Error Receiving File '.$savefile);
}
ELSE
{
echo trim('Successfully received file');
}
}
?>

Nick_W

10:05 pm on Sep 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try:

$file=$HTTP_POST_FILES['userfile']['name'];

$savefile = "C:\maxdata\FTPAdmin\SendFilesHere\UploadForm\".trim($file);

I think that'll work....

Nick

scratch

10:29 pm on Sep 23, 2002 (gmt 0)

10+ Year Member


Thank you very much...
with double quotes as you have it
$savefile = "C:\maxdata\FTPAdmin\SendFilesHere\UploadForm\".trim($file);

results in--
Parse error: parse error, unexpected $ in c:\inetpub\wwwroot\easyftp\sendfiles.php on line 40
Line 40 is the end of file

I think the quote is getting escaped out by the slash, how do I have it just be a slash.
I tried single quotes and got this error
Parse error: parse error, unexpected T_STRING in c:\inetpub\wwwroot\easyftp\sendfiles.php on line 30
Line 30 is the error copying file

What is T_STRING

scratch

11:42 pm on Sep 23, 2002 (gmt 0)

10+ Year Member


Okay i think i figured it out, I got that script to finally work

// in all windows paths instead of / and " on each side make it work on my windows system.
Now i just have to simplify out all the debugging type stuff and enable multiple file uploads...
Thanks for the help

<?php
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
{
echo $HTTP_POST_FILES['userfile']['tmp_name']." is temp name<BR>";
echo $HTTP_POST_FILES['userfile']['name']." is real name<BR>";
$realname = trim($HTTP_POST_FILES['userfile']['name']);
$upfile = trim($HTTP_POST_FILES['userfile']['tmp_name']);
$file=$HTTP_POST_FILES['userfile']['name'];
$savefile = "C:\\maxdata\\FTPAdmin\\SendFilesHere\\UploadForm\\".trim($file);
echo $savefile;

IF (!copy($upfile,$savefile))
{
echo 'Error Receiving File';
}
ELSE
{
echo trim('Successfully received file');
}

}
?>

jatar_k

1:03 am on Sep 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] scratch

scratch

4:15 pm on Sep 24, 2002 (gmt 0)

10+ Year Member


I Think I am going to be in these forums a lot. It's nice to know there is a place i can go when i get over my head. I think just posting the problem in itself helped a lot. :)

jatar_k

4:19 pm on Sep 24, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It often helps just to get a second set of eyes on it when you have been staring at it for entirely too long.

Glad to have you here. ;)