Hello-
I could use some help and I've been pulling my hair out for a few hours on this.
I'm trying to build a page that will upload a file via HTTP. It will accept the file and move it from the tmp location that PHP stores the file and put it in a file location.
I'm using move_uploaded_file(source,destination) and it doesn't seem to be working. The file is not there and my script confirms that PHP returns FALSE when I try testing it. Is there some way I can find out what is wrong?
Here is the php page followed by the form page:
uploadconfirm.php page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>File Upload Confirmation</title>
</head>
<body>
<?php
$currentdir = getcwd();
$uploadfile = "/var/www/html/upload/testfile.txt";
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload could not be completed\n";
}
echo 'More info:';
print_r($_FILES);
print "</pre>";
?>
</body>
</html>
HERE is the FORM PAGE (prospect uploader):
<html>
<head>
<title>Prospect Uploader</title>
</head>
<body>
<p> </p>
<div align="center">
PROSPECT UPLOADER
</div>
<p> </p>
<p><br>
<br>
<br>
<br>
</p>
<div align="center">
<form enctype="multipart/form-data" action="/uploadconfirm.php" method="POST">
<table width="100%" border="0" cellspacing="5">
<tr>
<td align="right" valign="middle">Type (or select) Filename:</td>
<td align="left" valign="middle"><input type="hidden" name="MAX_FILE_SIZE" value="512000" /><input name="uploadFile" type="file" size="30"> </td>
</tr>
<tr>
<td> </td>
<td align="left" valign="middle"><input name="submit" type="submit" value="Upload File"></td>
</tr>
</table>
</form>
</div>
</body>
</html>