PHP上传图像与表单不工作 [英] php upload image with form not working
本文介绍了PHP上传图像与表单不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以看到我做错了什么?
部分表单:
< form id =register-Formname =register-Formmethod =postenctype =multipart / form-dataaction =exec.php>
< div class =register-line>
< div class =ricon>< i class =fa fa-male>< / i> < / DIV>
picture
< input id =filetype =filename =fileclass =register-text> < /输入>
< / div>
exec.php代码
$ target_path =/ images /;
$ target_path = $ target_path。 basename($ _FILES ['file'] ['name']);
if(move_uploaded_file($ _ FILES ['file'] ['tmp_name'],$ target_path)){
// succes
} else {
//没有任何
}
解决方案
/ p>
$ temp = $ _FILES [file] [tmp_name];
$ image = basename($ _ FILES [file] [name]);
$ img =images /\".$ image;
move_uploaded_file($ temp,$ img);
echo< img src = images /\".$ image'/>;
I tried a lot suggestions at other people's threats about the same problem, but they didn't work. Can anyone see what I'm doing wrong?
Part of my form:
<form id="register-Form" name="register-Form" method="post" enctype="multipart/form-data" action="exec.php">
<div class="register-line">
<div class="ricon"><i class="fa fa-male"></i> </div>
picture
<input id="file" type="file" name="file" class="register-text"> </input>
</div>
exec.php code
$target_path = "/images/";
$target_path = $target_path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
//succes
} else{
//nothing
}
解决方案
try with this code
$temp = $_FILES["file"]["tmp_name"];
$image = basename($_FILES["file"]["name"]);
$img = "images/".$image;
move_uploaded_file($temp, $img);
echo "<img src=images/".$image' />";
这篇关于PHP上传图像与表单不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文