Click to See Complete Forum and Search --> : Help for file uploading


se_are
October 27th, 2005, 11:44 AM
Hello to everybody!
I've written a short PHP script for menaging the file uploading. the problem is that it doesn't upload every kind of file but only some (for ex. .txt and .doc). If someone can tell me why. i'd be grateful. Thanks and byez
Follows the code:


$uploaddir="C:/apache2triad/htdocs/tu4tu/Uploads/"; //Set the upload directory in the server machine

if((isset($_POST['action'])) && ($_POST['action'] == 'Alttach')) {

$uploadfile=$uploaddir.$_FILES['userfile']['name'];

echo $_FILES['userfile']['tmp_name'];

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {

echo "<br>".basename($uploadfile);
?>
<table>
<tr>
<td>File uploaded!</td>
</tr>
</table>
<?php } else {
?>
<table>
<tr>
<td>File not uploaded!</td>
</tr>
</table>
<?php
}
}
?>

<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<input type="file" name="userfile">
<input type="submit" name="action" value="Attach">
</form>

PeejAvery
October 27th, 2005, 12:33 PM
If it is only uploading certain file types, the problem is most likely the server restrictions. Check your server settings to see what MIME types it handles.

se_are
November 1st, 2005, 06:28 AM
Problem solved!!
As you said it was a configuration problem.
I left the POST_UPLOAD_SIZE set at 2 MB :D (retard)!
Thank you wery much!