Using system;
Using system. Web;
Using system. Web. UI;
Using system. IO;
Namespace webdb. Classes
{
///
/// Summary of uploadfile.
///
Public class uploadfile
{
Public uploadfile ()
{
//
// Todo: add the constructor logic here
//
}
///
/// Upload a file without Parameters
///
///
Public String getsqlfile ()
{
String sqlfile = "";
String Path = httpcontext. Current. Request. physicalapplicationpath. tostring () + "/upload ";
If (directory. exists (PATH ))
{
}
Else
{
Directory. createdirectory (PATH );
}
Httpfilecollection files = httpcontext. Current. Request. files;
If (files [0]. filename. tostring (). length> 0)
{
String filename = files [0]. filename. tostring ();
String datestr = datetime. Now. tostring ("yyyymmddhmmss") + datetime. Now. millisecond;
String ext = filename. substring (filename. lastindexof ("."));
Files [0]. saveas (path + "\" + datestr + ext );
Sqlfile = datestr + ext;
}
Else
{
}
Return sqlfile;
}
Public String getsqlfile (string DIR)
{
String sqlfile = "";
String Path = httpcontext. Current. Request. physicalapplicationpath. tostring () + "/upload /";
Path + = "\" + dir;
If (directory. exists (PATH ))
{
}
Else
{
Directory. createdirectory (PATH );
}
Httpfilecollection files = httpcontext. Current. Request. files;
If (files [0]. filename. tostring (). length> 0)
{
String filename = files [0]. filename. tostring ();
String datestr = datetime. Now. tostring ("yyyymmddhmmss") + datetime. Now. millisecond;
String ext = filename. substring (filename. lastindexof ("."));
Files [0]. saveas (path + "/" + datestr + ext );
Sqlfile = datestr + ext;
}
Else
{
}
Return sqlfile;
}
}
}