为什么此代码显示错误,因为名称上传器在当前上下文中不存在? [英] why this code is showing the error as the name uploader could not exists in current context?
本文介绍了为什么此代码显示错误,因为名称上传器在当前上下文中不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以基本上我编写了导入excel的代码并将其保存在godaddy域中但是如果我尝试运行此代码它会显示错误上传者在当前上下文中不存在这里缺少什么?
代码是:
so basically i wrote code for importing excel and saving it on godaddy domain but if i try to run this code it shows me error the uploader could not exists in current context what m missing here?
code is:
private String uploadAttachmentOnServer(FileUpload fileUpload)
{
String fileName = null;
int filesize = 0;
try
{
fileName = fileUpload.FileName;
filesize = fileUpload.FileBytes.Length;
String fileType;
String fileSize;
String destinationPath = Server.MapPath("./ExcelFiles/"); // ExcelFiles is folder name
String extension = Uploader.fileUpload(fileUpload, destinationPath, out fileType, out fileSize);
String fileVirtualPath = null;
if (extension != null)
{
fileVirtualPath = "../ExcelFiles/" + fileUpload.FileName;
return destinationPath + extension;
}
return null;
}
catch (Exception ex)
{
throw ex;
}
return null;
}
推荐答案
代码行中的Uploader是什么
What is "Uploader" in your code line
String extension = Uploader.fileUpload(fileUpload, destinationPath, out fileType, out fileSize);
你在代码中使用它必须是一个带有静态方法的类fileUpload()
或者你正在使用任何一个。在代码中使用dll而不是在使用语句将其添加到顶部。
as you used it in your code It must be a either a class with static method fileUpload()
or you are using any .dll in your code and not adding it at top as using statement.
这篇关于为什么此代码显示错误,因为名称上传器在当前上下文中不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文