php上传文件脚本在asp中转换

时间:2011-02-02 18:33:21

标签: php file-upload asp-classic

我有以下表格:

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

对于上传文件的uploader.php,这里是代码:

$target_path = "uploads/";
$target_path = $target_path . basename( $HTTP_POST_FILES['uploadedfile']['name']); 
if(copy($HTTP_POST_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

由于我打算将此代码移至IIS,您是否可以帮助重写uploader.php代码将其转换为asp,以便我可以将我的格式更改为'uploader.asp'? 如果不可能,我怎么能用网络服务呢?

谢谢,

此致

1 个答案:

答案 0 :(得分:1)

不确定您是否尝试过搜索与ASP相关的“表单/上传”内容..很容易找到:

http://www.asp101.com/resources/aspupload.asp

<HTML>  
<BODY>  
<%  
Set Upload = Server.CreateObject("Persits.Upload.1")  
Count = Upload.Save("c:\upload") 
%>
<% = Count %> files uploaded.  
</BODY>  
</HTML>

这是一个简单的上传表单,有很多例子。查看链接进行搜索以供参考,因此不适合为您工作的人。这是为了获得你所坚持的问题/问题的答案。