note 57647 rejected from features.file-upload.common-pitfalls by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 10 Oct 2005 06:53:11 +0000 |
| Subject: | note 57647 rejected from features.file-upload.common-pitfalls by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96774@lists.php.net to get a copy of this message | ||
Note Submitter: paulwd at tpg dot com dot au
----
I don't understand anything about what you guys are saying!
I'm totally new to PHP and have no idea how to get my PHP attach script to work.
I have tried everyscript and nothing works.
I think it may have something to do with my file permissions however I have everything set to CHMOD
777
What am I doing wrong?
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
<html>
<head>
<title>A simple file upload form</title>
<link href="css/employsa_new.css" rel="stylesheet"
type="text/css">
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #0099CC;
}
.style4 {
color: #FFFFFF;
font-weight: bold;
}
.style8 {color: #FFCC66; font-weight: bold; font-size: 12px; }
-->
</style></head>
<body>
<form action="upload.php" enctype="multipart/form-data"
method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<table width="100%" border="0" cellspacing="0"
cellpadding="3">
<tr>
<td><span class="style8">Use the 'Browse...' button
</span></td>
</tr>
<tr>
<td><span class="style8">to find the file you want to
Attach</span></td>
</tr>
<tr>
<td><span class="style8">then click
'Upload' to add it to this form</span></td>
</tr>
<tr>
<td><span class="style8">Valid file extensions: .pdf .txt
.zip</span></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p><span class="style4">File to Upload:</span>
<input type="file" name="fileupload"></p>
<p><input type="submit" value="Upload">
</p>
</form>
</body>
</html>