Home > Backend Development > PHP Tutorial > 下传图片的有关问题

下传图片的有关问题

WBOY
Release: 2016-06-13 13:16:09
Original
901 people have browsed it

上传图片的问题
ajax.js

JScript code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><script language="javascript" type="text/javascript">
$(document).ready(function(){   
 
   $("#button").click(function(){          
    postdata();                                    
  });
});
function postdata(){    
    $.ajax({                                            
    type: "POST",                                  
    url: "upload.php",   
    dataType:"html",                                  
    data: "filename="+$("#filename").val(),  
    
    success: function (msg){ 
                
    document.getElementById("sss").innerHTML=msg;
    alert(msg);               
    }
  });
 
}
</script>
Copy after login


upload.php:

echo $_POST['filename') //有值
print_r($_FILES['filename']);//没有值


请问怎么传给后台$_FILES['filename']就有值了。。。谢谢各位

------解决方案--------------------
.ajax上传文件,应该不只是单单的,穿上去文件名就行了。你还是考虑用上传插件吧
http://blog.163.com/zhou_shj/blog/static/6555644420104503248217/
------解决方案--------------------
这样是传不了的,我之前也远道过这个问题,要么用插件,要么用原生的js写ajax就可以上传文件
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template