在ASP中上传文件 [英] File uploading in ASP
本文介绍了在ASP中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们有一个asp和javascript代码片段,我们正在使用它们通过在线应用程序上传文件.
当前,我们面临的问题是该应用程序允许我们从E/F驱动器上载文件,但不允许我们从C驱动器上载.
应用程序引发警告消息,因为文件不存在或访问被拒绝...
ASP代码片段
we have a asp and javascript code snipet which we are using to upload files via online application.
currently we are facing an issue like the application is allowing us to upload a file from E/F drive but not allowing us to upload from C drive.
application throwing an alert message as File not exist or access denied...
ASP CODE SNIPET
case "FileExist"
sFileName = Request.QueryString("FileName")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(sFileName) = true then
sResult = "Success"
Else
sResult = "Not Success"
End If
Set objFSO = Nothing
Java script code
for (var i=1; i<=(document.getElementById('tblFile').rows.length)-1; i++)
{
if (IsEmpty('cmdBrowse' + i, 'SELECT', 'File', 'Y') == false)
return false;
sFileName = escape(document.getElementById('cmdBrowse' + i).value).replace(gSpecialChar,'%2b');
var sURL = "../ADO_Common.asp?PurposeName=FileExist&FileName=" + sFileName;
// alert(sURL);
oXMLHTTP.open( "POST", sURL, false );
oXMLHTTP.send();
if (oXMLHTTP.responseText != "Success")
{
alert("File Does Not Exists Or Permission Denied...")
return false;
}
}
请帮助我解决此问题...
Please help me on this to resolve this issue...
推荐答案
使用IIS时,授予IUSR_machinename
的权限对于这种情况很重要.
如果您没有对IUSR_machinename
的C驱动器的写入权限,则上述脚本中将发生错误.
此处讨论/解释的内容相同:使用FileSystemObject写入文本文件 [ ^ ]
如果请求被模拟,那么您需要确保模拟的用户具有安全权限.
When you are using IIS, the permissions granted toIUSR_machinename
is important for such scenarios.
If you do not have write permission to the C drive forIUSR_machinename
, an error will occur in the above script.
Same thing discussed/explained here: Using the FileSystemObject to Write to Text Files [^]
In case, the requests are impersonated, then you need to make sure that the user impersonated has the security permissions.
这篇关于在ASP中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文