John Dunlop <us*********@john.dunlop.name> wrote in message news:<MP************************@News.Individual.N ET>...
Simon wrote:
[Concerning the second example from "PHP: Handling file uploads -
Manual", <http://www.php.net/manual/en/features.file-upload.php>:]
parse error line 22
print "File is valid, and was successfully uploaded. ";
I have taken the form and script exactly as it is in the manual
Therein lies the problem. The fault is entirely the Manual's; its
inconsistent, and sometimes ignorant and clueless, style of presenting
examples caused this. I stress this is *not* your fault.
If you look closely, you'll find the first two characters of line
twenty-two aren't normal spaces but, probably, no-break spaces, which
are the cause of the parse error (at least they are in my version of
PHP). Viewing the source, one finds the offending line:
print [ ... ]
Two solutions: either substitute normal spaces for those no-break
spaces or simply remove them. Hopefully you'll straighten out the
other errors (actually, warnings) you enumerated in this thread.
John
I now have the form as my index.php which works fine.
<?php
echo "<title>File Upload</title>";
echo "<h1 align=\"center\">File Upload</h1>";
echo "<div align=\"center\"><b></b><br>";
echo "<b></b><br>";
echo "<b></b></div><br>";
echo "<div align=\"center\">";
echo "<style type=\"text/css\">
BODY{font-family:Verdana, Arial, Helvetica, sans-serif}
</style><form method=post action=\"tmp/upload.php\"
enctype=\"multipart/form-data\">
<p><strong>File to Upload :</strong><br><input type=file name=img1
size=30></p>
<p><input type=submit value=\"Upload File\"></p></form>";
?>
The echo statements at the top are for my own text .
The upload.php script on second file is .
<?php
$webServer="";
echo "<title>File Upload</title>";
echo "<h1 align=\"center\">File Upload</h1>";
echo "<div align=\"center\"><b></b><br>";
echo "<b></b><br>";
echo "<b></b></div><br>";
echo "<div align=\"center\">";
echo "<style type=\"text/css\">
BODY{font-family:Verdana, Arial, Helvetica, sans-serif}
</style>";
# Check whether file is uploaded successfully
if($img1_name!=""){
@copy("$img1","$webServer$img1_name") or die("Couldn't copy the
file");
}
else{
die("No input file specified!$img1_name");
}
echo "<html><head><title>Successful File
Upload</title></head><body><h2>Success!</h2>
<p>You sent : $img1_name, a $img1_size byte file with a mime type of
$img1_type.</p>
<a href=\"/index.php\">Upload another file</a></body></html>";
?>
I dont no why this combination works I will break it down over the
next week or so.
My next task would be to would be to use this script and try to extend
it to upload say five files at one time. any ideas.
regards
Simon