Parse error: syntax error, unexpected 'userfile' (T_STRING)

Alles, was PHP betrifft, kann hier besprochen werden.

Parse error: syntax error, unexpected 'userfile' (T_STRING)

Postby tiagoarcosta » 10. August 2014 13:26

I created two files: "index.html" and "upload.php".
The "index.html" contains a form for sending files as shown below:
-------------------------------------------------------------------------------------
<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
-------------------------------------------------------------------------------------
The contents of the file "upload.php" is shown below:
-------------------------------------------------------------------------------------
<?php
$uploaddir = 'C:\Users\UserName\Documents\uploads\';
$uploadfile = $uploaddir.$_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {
print "The file is valid and do run with success!";
print_r($_FILES);
} else {
print "Error!";
print_r($_FILES);
}
print "</pre>";
?>
-------------------------------------------------------------------------------------
I changed the following fields in the php configuration file called "php.ini":
-------------------------------------------------------------------------------------
max_execution_time=60000000000

max_input_time=60000000000

memory_limit=1024M

post_max_size=1024M

upload_max_filesize=1024M
-------------------------------------------------------------------------------------
I did it so I could upload files up to 1GB.
However, when performing the procedure for sending files by the browser, the file "upload.php" returns the following error messages:
-------------------------------------------------------------------------------------
Parse error: syntax error, unexpected 'userfile' (T_STRING) in C:\Users\UserName\Documents\scripts\upload.php on line 7
-------------------------------------------------------------------------------------
What do to do upload files?
tiagoarcosta
 
Posts: 3
Joined: 09. August 2014 01:56
XAMPP Version: 5.5.19
Operating System: Windows 8 Single Language

Re: Parse error: syntax error, unexpected 'userfile' (T_STRI

Postby Nobbie » 10. August 2014 15:16

tiagoarcosta wrote:What do to do upload files?


Learn to find your bugs. You made a severe syntax error. A backslash is a special Metacharactor for PHP Strings.
Nobbie
 
Posts: 6579
Joined: 09. March 2008 13:04


Return to PHP

Who is online

Users browsing this forum: No registered users and 6 guests