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

下传图片的有关问题

WBOY
WBOYOriginal
2016-06-13 13:16:09835browse

上传图片的问题
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>


upload.php:

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


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

------解决方案--------------------
.ajax上传文件,应该不只是单单的,穿上去文件名就行了。你还是考虑用上传插件吧
http://blog.163.com/zhou_shj/blog/static/6555644420104503248217/
------解决方案--------------------
这样是传不了的,我之前也远道过这个问题,要么用插件,要么用原生的js写ajax就可以上传文件
Statement:
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