error in code for file upload script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

error in code for file upload script

Post 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!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
bruceg
Forum Contributor
Posts: 174
Joined: Wed Mar 16, 2005 11:07 am
Location: Morrisville, NC
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
Last edited by Chris Corbyn on Wed Jul 06, 2005 5:14 pm, edited 2 times in total.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

missing the comma you are.

use move_uploaded_file() instead you should use...
Last edited by Burrito on Wed Jul 06, 2005 5:13 pm, edited 1 time in total.
Post Reply