note 57647 added to features.file-upload.common-pitfalls
| From: | paulwd at tpg dot com dot au | Date: | Mon, 10 Oct 2005 05:48:24 +0000 |
| Subject: | note 57647 added to features.file-upload.common-pitfalls | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96770@lists.php.net to get a copy of this message | ||
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>
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.common-pitfalls.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57647
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57647&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57647&report=yes
Search -- http://master.php.net/manage/user-notes.php