Forum Moderators: mack

Message Too Old, No Replies

PHP error :(

new to php and getting error msg

         

localoca

6:56 pm on Aug 4, 2003 (gmt 0)

10+ Year Member



Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Group\Apache2\htdocs\do_upload.php on line 3

I keep on getting this error. I'm new to PHP and i don't quite understand why i'm getting it, i checked the script and it looks fine to me but obviously i'm missing something here :(

this is my script(very very simple):
<?
if ($_FILES['img1']!= "") {
@copy($_FILES['img1']['tmp_name'], "c:\program files\apache group\apache2\htdocs\" .$_FILES['img1']['name']) or die ("Couldn't copy the file");
} else {
die("No input file specified");
}
?>

<html>
<head>
<title> Successfule file upload</title>
</head>
<body>
<h1> Success! <h1>
<p> You sent: <? echo $_FILES['img1']['name'];?>, a <? echo $_FILES['img1']['size'];?> byte file with a mime type of <? echo $_FILES['img1']['type'];?>.</p>
</body>
</html>

help please :(

jatar_k

7:13 pm on Aug 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld localoca,

Which is line 3?

We have a sweet little image upload script from Birdman that might help you out as well
Bag-O-Tricks for PHP II [webmasterworld.com]
msg #29

localoca

7:15 pm on Aug 4, 2003 (gmt 0)

10+ Year Member



Hi :)
Thanx for the welcome :)

Line 3 would be:

@copy($_FILES['img1']['tmp_name'], "c:\program files\apache group\apache2\htdocs\" .$_FILES['img1']['name']) or die ("Couldn't copy the file");

i'm still looking at it now to try and figure this out =/

Oh and thank you for the script :) i'll be sure to try that one out too :)

jatar_k

7:27 pm on Aug 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the only thing that comes to mind is the spaces in the path maybe try moving it to somewhere where there are no spaces to see if that is it (like the present directory).

also you might want to look at move_uploaded_file [ca2.php.net] as well.

vincevincevince

7:29 pm on Aug 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



extending what jatar_k said:

try %20 instead of space, or convert them into olde DOS paths?

localoca

7:42 pm on Aug 4, 2003 (gmt 0)

10+ Year Member



i found my mistake :)

@copy($_FILES['img1']['tmp_name'], "c:\program files\apache group\apache2\htdocs\" .$_FILES['img1']['name']) or die("Couldn't copy the file");

in the "c:\program files\apache group\apache2\htdocs\" i needed to include a second \ so that it looked like this:

@copy($_FILES['img1']['tmp_name'], "c:\program files\apache group\apache2\htdocs\\" .$_FILES['img1']['name']) or die("Couldn't copy the file");

thanks guys :)

g1smd

12:06 am on Aug 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The first \ of the close pair inadvertantly escaped the quotes when it was the only one, I would think.