-2

嗨,我想要一个脚本,它允许用户上传他们的图像以及我要求的一些信息,例如图像名称 url 它的 id 像这样。我找到了一些上传脚本,但这不是我所要求的。所以任何人都可以建议我一些脚本。

4

1 回答 1

0
<form id="uploadform" name="uploadfile" action="uploadprocess.php" method="POST" enctype="multipart/form-data"  ">


                <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
                <input id="uploadfile" type="file"  name="uploadfile"  />  
//create more input fields as you want 
</form>

在uploadprocess.php

 $whitelist = array(".png");//create while list for all items as you want
                     foreach ($whitelist as $item)
                         {

                            if(preg_match("/$item\$/i", $_FILES['uploadfile']['name']))
                                    {
                                        $uploaddir='uploads/';
                                        $uploadfile=mysql_prep($uploaddir.basename($_FILES['uploadfile']['name']));
                                        $access=true;
                                    }
                         }
if($access){

if(move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile) ) 
                               {
                                    $name=mysql_prep(($_FILES['uploadfile']['name']));
                                    $type=mysql_prep(($_FILES['uploadfile']['type']));

                                    $size= intval($_FILES['uploadfile']['size']);
                                 //create more data as user input
// and insert into database

                                    $query="INSERT INTO upload_file (name,type,created) VALUES ('{$name}','{$type}',NOW())";
                                    $result=mysql_query($query);


}
于 2012-09-20T06:05:04.720 回答