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>
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>