移动ASP的上传文件(move uploaded file for ASP)
我知道用PHP移动上传的文件
<?php if( isset($_FILES["myfile"]) ) { $target = basename($_FILES["myfile"]["name"]); if(move_uploaded_file($_FILES["myfile"]["tmp_name"],"./temp/".$target)) { $res = array("success"=>true,"file_name"=>$_FILES["myfile"]["name"],"size"=>$_FILES["myfile"]["size"]); } else $res = array("success"=>false,"desc"=>"no"); echo json_encode($res); } ?>但我不知道ASPX。
现在我需要ASPX中的PHP(上面)等文件上传代码。 任何代码来解决我的问题?
预先感谢。
I know move the uploaded file in PHP
<?php if( isset($_FILES["myfile"]) ) { $target = basename($_FILES["myfile"]["name"]); if(move_uploaded_file($_FILES["myfile"]["tmp_name"],"./temp/".$target)) { $res = array("success"=>true,"file_name"=>$_FILES["myfile"]["name"],"size"=>$_FILES["myfile"]["size"]); } else $res = array("success"=>false,"desc"=>"no"); echo json_encode($res); } ?>But I don't know the ASPX.
Now I need file upload code like PHP(above) in ASPX. any code to solve my problem?
Thank in advance.
最满意答案
有一个很好的例子: http : //msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx
只需使用FileUpload.SaveAs(...)函数将上传的文件保存在服务器上的所需位置即可
There is a good example at: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx
Just use the FileUpload.SaveAs(...) function to save the uploaded file where you want on the server
更多推荐
发布评论