PHP图像上载脚本的HTML表单

use*_*799 5 php file-upload

任何人都可以给我这个PHP图像上传脚本的HTML代码.我真的需要它,如果有人能帮助我,我会感激你.

这是PHP代码:

if(isset($_POST['upload'])) {

$allowed_filetypes = array('.jpg','.jpeg','.png','.gif');
$max_filesize = 10485760;
$upload_path = 'uploads/';
$description = $_POST['imgdesc'];

$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);

if(!in_array($ext,$allowed_filetypes))
  die('The file you attempted to upload is not allowed.');

if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
  die('The file you attempted to upload is too large.');

if(!is_writable($upload_path))
  die('You cannot upload to the specified directory, please CHMOD it to 777.');

if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)) {
   $query = "INSERT INTO uploads (name, description) VALUES ($filename, $description)"; 
   mysql_query($query);

echo 'Your file upload was successful!';


} else {
     echo 'There was an error during the file upload.  Please try again.';
}
}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ura 11

我偶然发现了这个确切的代码在这里你去找html

<form action="/script.php" method="post" enctype="multipart/form-data">
    <input type="file" name="userfile"/>
    <input type="text" name="imgdec">
    <button name="upload" type="submit" value="Submit">
</form>
Run Code Online (Sandbox Code Playgroud)