php - Browse button for file upload 404 file directory not found -
hi trying create upload section website, have looked @ multiple websites , examples such as:
i have found out there multiple ways these can go wrong example mysql injection each due them using $_files["file"]["type"]
. have started follow link instead due being php them selves, php documentation
ok point have problem code have @ moment have simple form runs php script check file upload , upload if correct , come invalid if isn't partially working, file uploads if large file 404 file or directory not found error if smaller file size works ideas.
the html form
<form enctype="multipart/form-data" action="upload_file.php" method="post"> <!-- max_file_size must precede file input field --> <input type="hidden" name="max_file_size" value="300000000" /> <!-- name of input element determines name in $_files array --> send file: <input name="userfile" type="file" /> <input type="submit" value="send file" />
and php file code
<?php // in php versions earlier 4.1.0, $http_post_files should used instead // of $_files. $uploaddir = './';// $uploadfile = $uploaddir . basename($_files['userfile']['name']); echo '<pre>'; if (move_uploaded_file($_files['userfile']['tmp_name'], $uploadfile)) { echo "file valid, , uploaded.\n"; } else { echo "possible file upload attack!\n"; } echo 'here more debugging info:'; print_r($_files); print "</pre>"; ?>
any ideas appreciated or if knows better example use.
the maximum file size may limited in php. in php.ini
, check following properties:
upload_max_filesize = 10m post_max_size = 10m
if makes no change, can try checking memory limit or maximum process time.
Comments
Post a Comment