Php file uploading code
To uploading a file, two changes must be
made to the standard HTML form. First, the initial FORM line must
include the code ENCTYPE = "multipart/form-data", which lets the
HTML know to expect a file as well other data.
Second, <input name="NAME" type="FILE" /> the element is used to create the necessary field.
Another trap is the size of uploaded files.
Although you can tell the browser the maximum size of file to upload, this is only a recommendation and it cannot ensure that your script won't be handed a file of a larger size. The danger is that an attacker will try a denial of service attack by sending you several large files in one request and filling up the filesystem in which PHP stores the decoded files. The php file uploading code: <form action="" method="post"> Select Filename: <input type="file" name="adFile"> <input type="submit" value="Upload"> </form> <?php move_uploaded_file ($_FILES['adFile'] ['tmp_name'], "../uploads/{$_FILES['adFile'] ['name']}") ?>
Set the post_max_size configuration option in php.ini to the
maximum size in bytes that you want:
post_max_size = 1024768 ; one megabyte The default 10 MB is probably larger than most sites require. |
Php file uploading code
PMA07:58
Categories: PHP