Page 1 of 1

error in code for file upload script

Posted: Wed Jul 06, 2005 4:43 pm
by bruceg
Hello,

I am trying out a PHP script that uploads a file to the server and I am receiving an error that states

"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Uploader.php on line 4"

this is line 4 of the code

Code: Select all

"/hsphere/local/home/bruceg/inspired-evolution.com/" . $_FILES['file'] ['name'] )
the page in question can be found at :

http://rror that states

"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /hsphere/local/home/bruceg/inspired-evolution.com/Uploader.php on line 4"

this is line 4 of the code

Code: Select all

"/hsphere/local/home/bruceg/inspired-evolution.com/" . $_FILES['file'] ['name'] )
the page in question can be found at :

http://www.inspired-evolution.com/File_Upload.php


if anyone sees anything wrong with the code please advise. I can provide all of the code being used if necessary.

thanks!

Posted: Wed Jul 06, 2005 4:47 pm
by Chris Corbyn
I see an error on line 4 ;)

EDIT | Lmao, if you read that post before I made this edit then good :P I wanted you to look closer.

It's syntactically wrong in multiple ways. You need echo() or something infront of it (perhaps $var = ). You also have a stray closing parentheses at the end, a gap between your array keys and no semi-colon delimiter on the very end ;)

Posted: Wed Jul 06, 2005 4:59 pm
by bruceg
sorry,

I should have posted tge entire block to make things more clear.

Code: Select all

<?php
    if( $_FILES['file'] ['name'] !="" )
    {copy ( $_FILES ['file'] ['tmp_name']
    "/hsphere/local/home/bruceg/inspired-evolution.com/" . $_FILES['file'] ['name'] )
    or die ( "Could not copy file" );
    }
    else die( No file specified" ) ; }
    ?>
the error occurs on the 4th line of this code. See post above for error msg.

Posted: Wed Jul 06, 2005 5:12 pm
by Chris Corbyn
Take the whitespace out from between your array keys and add the comma to separate the function paramaters (comma needs to be on end of line 3).

EDIT | You're missing the opening double quote in the last die() statement too. Having an editor with snytax highlighting helps gretaly to prevent such errors ;)

Posted: Wed Jul 06, 2005 5:12 pm
by Burrito
missing the comma you are.

use move_uploaded_file() instead you should use...