[英]Php script for multiple file upload
我正在为打开的购物车制作Cpanel,并且必须上传3张这样的产品的图片
<label for="password" class="control-label"><b>Product image:</b></label>
<div class="controls">
<input type="file" name="Upload" id="password" class="span9 required" required />
</div>
<label for="password" class="control-label"><b>Product image:</b></label>
<div class="controls">
<input type="file" name="Upload" id="password" class="span9 required" required />
</div>
<label for="password" class="control-label"><b>Product image:</b></label>
<div class="controls">
<input type="file" name="Upload" id="password" class="span9 required" required />
</div>
我搜索了许多文件上传代码,但是没有一个可以使我的工作变得容易。 我正在一个Framework中工作,因此我会将这些数据发送到数据库类: $this->mlogin->dbfunction($POST,$image1,$image2,$image3);
我的插入查询将在哪里执行
这是数据库代码
public function product_upload($_POST,$path) {
$this->insert_query="INSERT INTO `_product`(
`_p_name`,
`_p_cat`,
`_p_brand`,
`_p_price`,
`_p_amount`,
`_p_image`,
`_p_dcrp`
)
VALUES(
'" .$_POST['name'] . "',
'" .$_POST['cat'] . "',
'" .$_POST['brand'] . "',
'" .$_POST['price'] . "',
'" .$_POST['avail'] . "',
'" .$path . "',
'" .$_POST['detail'] . "'
)";
return $this->select();
}
除了对未过滤输入的安全性担忧外,在$ _POST中找不到上载的文件,但在$ _FILES中找到更复杂的布局。
只需做一个var_output($ _ FILES)来检查它的内容,并在这里参考文档: http : //php.net/manual/en/features.file-upload.php
要记住的步骤:
$ _FILES的布局:
$_FILES[$fieldname]['name'] // The original name of the file on the client machine.
$_FILES[$fieldname]['type'] // The mime type of the file. Unsafe! Dont rely on it!
$_FILES[$fieldname]['size'] // The size, in bytes, of the uploaded file.
$_FILES[$fieldname]['tmp_name'] // The temporary filename of the file on the server.
$_FILES[$fieldname]['error'] // The error code associated with this file upload.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.