PDA

View Full Version : What is wrong with this script


xiaodao
05-12-2005, 12:26 PM
it drives me crazy, nothing shows, the file cannot be uploaded at all

<?php
$path="'/var/public_html/test/";
$pathfile=$path.basename($_FILES['attachment']['name']);
echo '<pre>';
if($_POST['submit']){
if($_FILES['attachment']['error']=="UPLOAD_ERR_OK"){
if (move_uploaded_file($_FILES['attachment']['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>";
}
}
?>
<table>
<form name="upload" method="post" action="upload.php">
<tr>
<td><input type="hidden" name="MAX_FILE_SIZE" value="102400"><input type="file" name="attachment"></td>
</tr>
<tr><td><input type="submit" name="submit" value="submit"></td></tr>
</form>
</table>

fci
05-12-2005, 01:21 PM
if($_FILES['attachment']['error']==UPLOAD_ERR_OK){
and.. you should be checking be at least checking file extension for security reasons (someone could upload a file that is .php).. and sometimes people do a MIME check if they only want certain file types uploaded.