Click here to Skip to main content
15,886,199 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Calling HTML page Pin
Anurag Gandhi1-Mar-09 18:53
professionalAnurag Gandhi1-Mar-09 18:53 
Questionfile upload control problem Pin
anujbanka17841-Mar-09 17:14
anujbanka17841-Mar-09 17:14 
AnswerRe: file upload control problem Pin
sarang_k1-Mar-09 17:25
sarang_k1-Mar-09 17:25 
AnswerRe: file upload control problem Pin
Rajeesh MP1-Mar-09 17:27
Rajeesh MP1-Mar-09 17:27 
GeneralRe: file upload control problem Pin
anujbanka17841-Mar-09 17:39
anujbanka17841-Mar-09 17:39 
GeneralRe: file upload control problem Pin
Rajeesh MP1-Mar-09 17:52
Rajeesh MP1-Mar-09 17:52 
GeneralRe: file upload control problem Pin
anujbanka17841-Mar-09 18:29
anujbanka17841-Mar-09 18:29 
QuestionProblem: Upload all the file in a folder to Server using JavaScript / web service Pin
Member 38548031-Mar-09 16:10
Member 38548031-Mar-09 16:10 
Hello

Problem: Upload all the file in a folder to Server using JavaScript / web service

I was trying to upload all the files from the specified folder from the client machine to the server.
At the client side, I used JavaScript to read the entire file from client machine
While looping through each file in the folder I call web service and pass the file content. I use webservice.htc to call web service

<html>
<head>
<title>Upload Files</title>
<script language="JavaScript">
var iCallID;
function InitializeService()
{
checkFile();
}

function ShowResult()
{
alert(event.result.value);
}
function checkFile()
{

var found=0;
var foldobj=new ActiveXObject("Scripting.FileSystemObject");
if((navigator.userAgent.indexOf('Win') != -1))
{
var myfolder=foldobj.GetFolder("c:\\Temp");
var z=myfolder.Files.Count;
var fil_col=myfolder.Files;
var en=new Enumerator(fil_col);
for(;!en.atEnd();en.moveNext())
{

var objFileIO = foldobj.GetFile("c:\\Temp\\" + en.item().Name);
var textStreamObject = objFileIO.OpenAsTextStream(1,-2);

var strFileContent = textStreamObject.ReadAll();

//Another code
var streamIO = objFileIO.OpenAsTextStream();
var strTransform = new Array();
for (i = 0; i < objFileIO.Size; i++) {
var strContent = streamIO.Read(1);
// strTransform[i] = strContent.charCodeAt(0);
strTransform[i] = strContent;

}
streamIO.Close();


var StrPath, StrFile, byteStream;
StrPath= "C:\\Test\\";
StrFile = en.item().Name;

service.useService("http://localhost:46967/MyWebService.asmx?wsdl", "UploadDocumentService");
service.UploadDocumentService.callService("UploadDocument",StrPath,StrFile,strFileContent);
//service.UploadDocumentService.callService("UploadDocument",StrPath,StrFile,strTransform);
}
}
return found;
}

</script>
</head>
<body onload="InitializeService()" id="service" style="behavior:url(webservice.htc)" onresult="ShowResult()">
</body>
</html>


At the server, I will write the file back to the specified folder location using FileStream.

[WebMethod]
public string UploadDocument(String strDocPath, String strFile, byte[] document)
{
try
{
string FullPath;

FullPath = AppPath + strFile;

// *** Write to file ***

// Specify file, instructions, and privelegdes
System.IO.FileStream file = new System.IO.FileStream(FullPath, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.Write, document.Length);


file.Write(document, 0, document.Length);

// Close file
file.Close();

}
catch (Exception)
{

throw;
}
return "Success";
}

Here is the problem it works fine for the text file as I use FileSystemObject and OpenAsTextStream .
But it if tried to upload .doc file, jpeg file etc.(I mean binary file )it fails, the file created with same size, but not able to open these files, says ‘file is corrupted ‘

Can I use
//Test another method
var adoStream, stream;
adoStream = new ActiveXObject("ADODB.Stream");
adoStream.Open();
adoStream.Type = 1;//adTypeBinary;
adoStream.LoadFromFile("c:\\Temp\\" + en.item().Name);
stream = adoStream.Read();
adoStream.Close();

//End

But I have some issue like will “ADODB.Stream” work on IE 5.1 or later. ?.

Any help is greatly appreciated..
QuestionMicosoft Word Interop Pin
Sam Horne1-Mar-09 14:49
Sam Horne1-Mar-09 14:49 
QuestionHow to change windows language bar setting Pin
Meax1-Mar-09 5:58
Meax1-Mar-09 5:58 
AnswerRe: How to change windows language bar setting Pin
Yusuf1-Mar-09 7:22
Yusuf1-Mar-09 7:22 
QuestionArrayList looping Pin
Sarfaraj Ahmed1-Mar-09 3:53
Sarfaraj Ahmed1-Mar-09 3:53 
AnswerRe: ArrayList looping Pin
Yusuf1-Mar-09 7:38
Yusuf1-Mar-09 7:38 
GeneralRe: ArrayList looping Pin
Sarfaraj Ahmed1-Mar-09 16:21
Sarfaraj Ahmed1-Mar-09 16:21 
GeneralRe: ArrayList looping Pin
Sarfaraj Ahmed1-Mar-09 16:28
Sarfaraj Ahmed1-Mar-09 16:28 
GeneralRe: ArrayList looping Pin
Yusuf2-Mar-09 2:38
Yusuf2-Mar-09 2:38 
AnswerRe: ArrayList looping Pin
Kunal Pawar1-Mar-09 22:30
Kunal Pawar1-Mar-09 22:30 
GeneralRe: ArrayList looping Pin
Yusuf2-Mar-09 2:09
Yusuf2-Mar-09 2:09 
QuestionRunTime Controls in Web Page Pin
Zeyad Jalil1-Mar-09 1:53
professionalZeyad Jalil1-Mar-09 1:53 
AnswerRe: RunTime Controls in Web Page Pin
Calin Tatar1-Mar-09 2:05
Calin Tatar1-Mar-09 2:05 
AnswerRe: RunTime Controls in Web Page Pin
Abhishek Sur1-Mar-09 2:19
professionalAbhishek Sur1-Mar-09 2:19 
QuestionRun methods of a runtime created object Pin
mehrdadc4828-Feb-09 21:16
mehrdadc4828-Feb-09 21:16 
AnswerRe: Run methods of a runtime created object Pin
Curtis Schlak.1-Mar-09 1:29
Curtis Schlak.1-Mar-09 1:29 
QuestionSending email in ASP.net Pin
rehal28-Feb-09 18:57
rehal28-Feb-09 18:57 
AnswerRe: Sending email in ASP.net Pin
netsooz (Amir Hamidi)28-Feb-09 19:38
netsooz (Amir Hamidi)28-Feb-09 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.