PHP Problem...
RWB
Icrontian
[PHP]<?php
if ( move_uploaded_file ($_FILES ,
"../uploads/{$_FILES }") )
{ print '<p> The file has been successfully uploaded </p>';
}
else
{
switch ($_FILES )
{ case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>[/PHP]
Creating a simple upload form, an html file is posting to the getfile.php page, but the file doesn't upload and it doesn't give me an error report.
It comes from this tutorial I am working on BTW.
http://www.htmlgoodies.com/beyond/php/article.php/3472561
I am also not entirely sure how the switch/case function works... I figured I might be able to tell if it gave me an error, but it does nothing... not even if I take it out and use a simple print statement for "else".
if ( move_uploaded_file ($_FILES ,
"../uploads/{$_FILES }") )
{ print '<p> The file has been successfully uploaded </p>';
}
else
{
switch ($_FILES )
{ case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>[/PHP]
Creating a simple upload form, an html file is posting to the getfile.php page, but the file doesn't upload and it doesn't give me an error report.
It comes from this tutorial I am working on BTW.
http://www.htmlgoodies.com/beyond/php/article.php/3472561
I am also not entirely sure how the switch/case function works... I figured I might be able to tell if it gave me an error, but it does nothing... not even if I take it out and use a simple print statement for "else".
0
Comments
ini_set('error_reporting', E_ALL);
That will turn it on .. on a per script basis
This:[php]$_FILES[/php]
Instead of this:[php]$_FILES [/php]
I don't know if that's what's screwing it up, but I've never seen the syntax written with that space.
[php]default: echo "<p>I don't know, this is what you sent me: ".$_FILES."</p>";
break;[/php]
You could try that with and without the space and see what happens... I imagine it will do something funky with the space, and without it the whole shebang will either work or you'll at least see what's in the error field
putfile.htm
[PHP]<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="getfile.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="hidden" name="MAX_FILE_SIZE" value="25000" />
<input type="submit" value="Upload File">
</form>
</body>
</html>[/PHP]
getfile.php
[PHP]<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
if ( move_uploaded_file ($_FILES ,
"../uploads/{$_FILES }") )
{ print '<p> The file has been successfully uploaded </p>';
}
else
{
switch ($_FILES )
{ default: echo "<p>I don't know, this is what you sent me: ".$_FILES ."</p>";
break;
case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>
</body>
</html>[/PHP]
I've removed the spaces between all the brackets as well, like so...
getfile.php modified
[PHP]<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
if ( move_uploaded_file ($_FILES,
"../uploads/{$_FILES}") )
{ print '<p> The file has been successfully uploaded </p>';
}
else
{
switch ($_FILES)
{ default: echo "<p>I don't know, this is what you sent me: ".$_FILES."</p>";
break;
case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>
</body>
</html>[/PHP]
I kind of feel that I messed up maybe in the putfile.htm page, somewhere... somehow... but I don't see it! lol
[php]<form action="getfile.php" method="post" enctype="multipart/form-data">[/php]
I think I am gonna move on to some newer tutorials I have found, retrace my steps and learn more. These seem nice:
http://devzone.zend.com/node/view/id/627
Sweet, it works now!!! Thanks.