PHP图片上传问题 [英] PHP image upload problem
本文介绍了PHP图片上传问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将表单中的图像上传到特定文件夹。但它不起作用。
有人可以帮助我吗?
HTML Code
I am trying to upload images in a form to a specific folder. But it doesn't work.
can anyone help me?
HTML Code
<div>
<p><font size="+1" color = 'red'>image must rename as category id & only upload .jpg format </br> max (h-95px / W 165px) </font></p>
<label for="img">Image:</label>
<input type="file" name="image" />
<input type="submit" name="submit" value="submit" />
</div>
php code
php code
if(isset($btnadd)){
$sql = "insert into category (cat_id,cat_name) values (:id,:cname)";
$stmt = $con ->prepare($sql);
$stmt->execute(array(':id'=>$id,':cname'=> $cname));
$result = $stmt->fetch(PDO::FETCH_ASSOC);
$tmp=$_FILES["file"]["tmp_name"];
$extension = explode("/", $_FILES["file"]["type"]);
$name=$id.".".$extension[1];
move_uploaded_file($tmp, "images/" . $id.".".$extension[1]);
推荐答案
btnadd)){
btnadd)){
sql = 插入类别(cat_id,cat_name)值(:id ,:CNAME)跨度>;
sql = "insert into category (cat_id,cat_name) values (:id,:cname)";
stmt =
stmt =
这篇关于PHP图片上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文