hessiess
October 27th, 2008, 08:54 AM
Hi, I'm trying to Wright a simple script to upload a file to a server, but for some reason all im managing to get is:
Files:Array
(
)
Notice: Undefined index: uploadfile in /srv/http/tests/upload.php on line 14
Notice: Undefined index: uploadfile in /srv/http/tests/upload.php on line 17
As the $_FILES array seems to be empty I'm guessing something wrong with the server config, which is installed on the same computer. which is running Arch, PHP is working and upload files is on.
upload.html
<html>
<head></head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="600000" />
<input name="uploadfile" type="file" />
<input type="submit" value="Send File" /> </form>
</body>
</html>
upload.php
<html>
<head></head>
<body>
<?php
echo "<pre>\n";
echo 'Files:';
print_r($_FILES);
echo "</pre>\n";
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['uploadfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile))
{
echo "worked\n";
}
else
{
echo "error\n";
}
echo "</pre>";
?>
</body>
</html>
Files:Array
(
)
Notice: Undefined index: uploadfile in /srv/http/tests/upload.php on line 14
Notice: Undefined index: uploadfile in /srv/http/tests/upload.php on line 17
As the $_FILES array seems to be empty I'm guessing something wrong with the server config, which is installed on the same computer. which is running Arch, PHP is working and upload files is on.
upload.html
<html>
<head></head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="600000" />
<input name="uploadfile" type="file" />
<input type="submit" value="Send File" /> </form>
</body>
</html>
upload.php
<html>
<head></head>
<body>
<?php
echo "<pre>\n";
echo 'Files:';
print_r($_FILES);
echo "</pre>\n";
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['uploadfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile))
{
echo "worked\n";
}
else
{
echo "error\n";
}
echo "</pre>";
?>
</body>
</html>