Why is the difference between a uploaded file using VB6, ASP.NET and a uploaded file using ASP.NET FileUpload Server Control?

I'm trying to develop Active X file upload component using VB6.

Like below list... Thanks for authors( Joseph Z. Xu (jzxu@napercom.com), Mohd Idzuan Alias (iklan2k@yahoo.com)).

--Client File upload Program source 

Dim WinHttpReq As WinHttp.WinHttpRequest
Const BOUNDARY = "Xu02=$"
Const HEADER = "--Xu02=$"
Const FOOTER = "--Xu02=$--"

Function UploadFiles(strFileName As Variant, strURL As String, DirPath As String, Optional postVar As String, _
                     Optional strUserName As String, Optional strPassword As String) As String

    Dim fname As String
    Dim strFile As String
    Dim strBody As String
    Dim aPostBody() As Byte
    Dim nFile As Integer
    Set WinHttpReq = New WinHttpRequest

    ' Turn error trapping on
    On Error GoTo SaveErrHandler

    ' Assemble an HTTP request.
    strURL = strURL & "?slots=" & CStr(UBound(strFileName) + 1) & "&" & postVar
    WinHttpReq.Open "POST", strURL, False
    Debug.Print strURL
    If strUserName <> "" And strPassword <> "" Then
        ' Set the user name and password.
        WinHttpReq.SetCredentials strUserName, strPassword, _
    End If
    '-------------------------- Becareful not to mingle too much here -----------------------------------
    ' Set the header
    WinHttpReq.SetRequestHeader "Content-Type", "multipart/form-data; boundary=" & BOUNDARY
    ' Assemble the body
    strBody = HEADER                        ' Starting tag
    For i = 0 To UBound(strFileName)
        ' Grap the name
        fname = strFileName(i)
        ' Grap the file
        strFile = getFile(DirPath & "\" & fname)
            strBody = strBody & vbCrLf & "Content-Disposition: form-data; name=""" & "upload" & _
            (i + 1) & """; filename=""" & fname & """ " & vbCrLf & "Content-type: file" & _
            vbCrLf & vbCrLf & strFile & vbCrLf
        If i < UBound(strFileName) Then
            strBody = strBody & "--Xu02=$" ' This is boundary tag between two files
        End If
        strFile = ""
    Next i
    strBody = strBody & FOOTER             ' Ending tag
    ' Because of binary zeros, post body has to convert to byte array
    aPostBody = StrConv(strBody, vbFromUnicode)
    ' Send the HTTP Request.
    WinHttpReq.Send aPostBody
    ' Display the status code and response headers.
    'UploadFiles = WinHttpReq.GetAllResponseHeaders & "  " & WinHttpReq.ResponseText
    UploadFiles = WinHttpReq.ResponseText
    Set WinHttpReq = Nothing
    Exit Function
    UploadFiles = Err.Description
    Set WinHttpReq = Nothing
End Function
Function getFile(strFileName As String) As String

    Dim strFile As String
    ' Grap the file
    nFile = FreeFile
    Open strFileName For Binary As #nFile
    strFile = String(LOF(nFile), " ")
    Get #nFile, , strFile
    Close #nFile
    getFile = strFile
End Function


--Server File upload Program source Upload.aspx

<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Private Const INFO_DIR As String = "C:\public\Wiki\"
    Public Shared requestCount As Integer
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim Loop1 As Integer
            Dim TempFileName As String
            Dim MyFileCollection As HttpFileCollection = Request.Files
            For Loop1 = 0 To MyFileCollection.Count - 1
                Dim file As HttpPostedFile = MyFileCollection(Loop1)
                ' Create a new file name.
                TempFileName = INFO_DIR & file.FileName

                ' Save the file.
            Next Loop1

    End Sub

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>제목 없음</title>
    <form id="form1" runat="server">


File Upload is OK. But the original file and the uploaded file aren't same(file size, file content...). Instead, the files using ASP.NET FileUpload server control are exactly same.

Is there any problem? Any clues?

How can I fix it?

Help..., please.

5/29/2008 7:41:27 AM
asp.net.client-side 24353 articles. 2 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 48


Similar Artilces:

Posting filepath in file upload control in .NET to the next page and uploading the file from second page
In our application (using C# .NET) there is a form with file upload options. After filling up the form details, the summary of the details need to be shown in the next page before committing the information into the database. Right now, Server.Control is used to transfer the contents to the next page and the form details are retrieved using Request.Form["control id"]. But this is not working for File upload control alone.File upload can not be done in the first page itself, as the foreign key in File upload table gets updated only in second page after confirmation. Therefore, is th...

without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible?
without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible? avdp211:without server side scripting, can we upload a file using client side scripting if destination folder and config file settings are known? is it possible? I don't think it is possible.You use the the HTML input file control and when you post the request, on the web server you need to read the data and save it to a file, so there has to be some interaction with the server to handle the post request.  Not possible vi...

How to identify the original file type and restrict the file uploading while using file upload control
 Hi asp.net , I am uploading a file using FileUpload control in asp.net using vb.net.I wrote the code to upload only PDF files. the user can change the extension and change to PDF . I have to check is the file original PDF or not then i have to upload the PDF files only . How to do this ??  Hi, Check the file Mime type for "application/pdf" by looking at the:  FileUpload1.PostedFile.ContentType RegardsSmcoxonNo Gem is ever polished without some friction. Hi smcoxon , Thanks For Replying ,But i found that there is no use using PostedFil...

file upload control for windows desktop application using vb.net
hi can anybody pls tell me the control for uploading a file in windows application using vb.net.I know that we have file upload control in asp.net for webforms as well as in html controls. But this time i've to create a desktop application and have a window form that allow user to upload the images,as well as text files etc through this window form. This is really urgent.Pls help. Thanks,Neha    In window forums you need to use SaveFileDialog to do the file saving... This forum is dedicatedly for Asp.Net related web development, so if you have any queries ...

When I upload a text file from client to server using stream, how can I guarantee that the uploaded text file can be displayed correctly?
When I upload a text file from client to server using stream, how can I guarantee that the uploaded text file can be displayed correctly? A user want to upload a text file from client PC to server (normally it is Windows 2003), but I'm not sure which OS it is in client, maybe it is a english version Windows or chinese Windows (default encoding is GB2312).so the encoding of text file in client maybe is ASCII or GB2312.I think that "StreamReader myRead= new StreamReader(FileUpload1.PostedFile.InputStream,Encoding.Default) will be run in server,so "Encoding.Default" will be the default encodin...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Upload multiple files to the server without using File Upload
I want to upload multiple files to the server without using input type file (File Upload). Is there a way to do this. What I want to do is retrieve multiple file paths (paths are displayed in a user control like text boxes) and upload those files to the server as a bunch. I tried to set the value of the File Upload cotrol (using javascript) but it was not succeed since attributes of the File Upload are readonly. (document.getElementById("fileUploadValue").value = "C:\Test.txt") Is there a way to override the values in File Upload control or is there a way to up...

How to upload an Outlook Message in File Upload control in .Net
Hi All, Is it possible to upload an outlook message from outlook in File Upload control.Please don't suggest to save the message onto the desktop and then upload it!   What I am after is really navigating to the outlook folders through the File Upload control and upload a message.  Thanks guys   If there is a way to do it, but it could be used to maliciously read someone's email folders, forgive me if I hope no one answers you. :)...

how to get author from file when upload using upload control using javascript
function CheckSchemaFileExistence() { var Schemafilename=document.getElementById('<%= this.flUploadB.ClientID %>').value;if(Schemafilename.length>0) {return true; } else { alert("File Name cannot be empty");return false; } }   we written code in button click . i need a file author name . how to find it can any tell me . thanks in advance Hi harish448 For your information, I know you want to get the file's author name, which from client-side But I think Not all type of files have the attribute of "author name" (I think on...

Add link buttons to each file uploaded using File upload control
Hi,   In my application I have one file upload control. When the user selectes a file to upload and when he clicks on Attach button I need to show him the file name of the file he selected to upload and also show the Remove link button after the file name. In this case I need to generate link button dynamically. I wrote a code like the following:protected void btnAttach_ServerClick(object sender, EventArgs e) {string strFileName = MyFile.PostedFile.FileName;string c = System.IO.Path.GetFileName(strFileName); listBoxAttachedFiles.Items.Add(c);LinkButton b = new LinkButton(); b.Te...

Is there any limitation of file types that file upload control can be used to upload?
I am working on a content management system which requires me to upload WebEx recording files (.wrf) through file upload control. But I am getting "internet explorer cannot display the webpage" error. It worked with other files types as txt, doc, xls, pdf, jpg, gif etc. Is it related to any security issue or just a bug with the file upload control?  Thank you. The file upload control doesn't have any file type limitations that I'm aware of, but it does have some size constraints.  By default, ASP.NET is configured to not accept any file's larger than 4...

file uploader save file on server and in database and upload this file on client
hi,i have a file uploader control user can attach files (.rar, .zip, etc) and store file folder and path in database. and another user can click of attach link and can download that file. how can i do this please solve out this problem. you can find your problem solution in this link and you can store the file name in your database server.http://www.aspnettutorials.com/tutorials/network/net-fileupload-aspnet2-csharp.aspxPlease Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.comhttp://www.mitatdotnet.blogspot.com As always there are many ways and which ...

How to use the Streams in VB.NET for uploading the file
hi friends, I want to upload an Excel file(very large 100,000 records) to the webserver using Vb.NET My code (given down) works well when i upload the file to the local directory. If I upload to the webserver, as the file size is large i want to make use of streams and upload the file. Please help me .. How to use the Streams in VB.NET for uploading the file Thanks in advanceProtected Sub btnUploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUploadButton.Click FileName.InnerHtml = FileField.PostedFile.FileName FileContent.I...

uploading files in Email using c#.net
I have a c#.net ASP webpage. Please let me if anyone can provide with a code for Attaching files.Thanking you.ABAK. Hi here is some code. MailMessage msgMail = new MailMessage();msgMail.To = sender address;msgMail.From = recepient address;msgMail.Subject = mail subject;msgMail.Body = body text;msgMail.Attachments.Add(new MailAttachment(your file path));SmtpMail.Send(msgMail); Hope it will help. try using the fileupload html control and change it to html webserver control. dim fileArr() as string = FileUpload.PostedFile.FileName.split("\") ' to create an array with items o...

How to upload files using System.Net.FtpWebRequest
Hi,How to upload files to linux server using System.Net.FtpWebRequest.Thanks in AdvanceSubhasis Chanda Hi May be this link will help you how to do that http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.aspx  BabaIf this post was useful to you, please Don't forget to click "Mark as Answer". Thanks You.:-) Thanks a lot.  Subhasis Chanda Hi Subhasis, If the post was useful,please mark as answer so other can get the benfit of it.   Thanks, MAamirBabaIf this post was useful to you, please Don't forget to click "Mark as Answer&quo...

Web resources about - Why is the difference between a uploaded file using VB6, ASP.NET and a uploaded file using ASP.NET FileUpload Server Control? - asp.net.client-side

Difference - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

3Q EARNINGS: Mark Zuckerberg on the Differences Between Messenger and WhatsApp
When Facebook announced its intent to acquire cross-platform messaging application WhatsApp in February, questions surfaced on whether WhatsApp ...

Facebook Tips: What’s the Difference between Top News and Most Recent?
The following is part of our series, Facebook Tips, which answers some of the most commonly asked questions about using Facebook. While we hope ...

World powers adopt UN Syria resolution to end civil war, but differences on Assad's future as leader ...
The UN Security Council unanimously adopts a resolution endorsing a peace process to end the Syrian war.

How a Fox News Poll Makes the Difference in CNN Debate
Rand Paul has Fox News to thank for making the cut in the main debate on CNN Tuesday night. The Kentucky Senator could have been relegated to ...

Differences Matter
I was struck by this paragraph in the Slate piece on our portfolio company YouNow this weekend: In theory, YouNow sounds a bit like Twitter’s ...

Debate showed differences between parties
Much of the commentary and analysis from Saturday night’s Democratic debate in New Hampshire will undoubtedly focus on the questions of national ...

Gender brain differences - Business Insider Deutschland
Scientists analyzed brain scans of more than 1,400 people to look for gender differences.

Can you spot the differences between fact-checking a GOP debate and whack-a-mole?
It shouldn’t come as any big surprise that Tuesday night’s Republican presidential debate was a bonanza for fact-checkers. Here are a few of ...

Northwestern MutualVoice: How 100 Women Are Making A Difference In Your Community
By Amanda Reaume You might not have heard about them, but it’s likely there are 100 women who are making a difference in your community through ...

Resources last updated: 12/26/2015 7:41:48 AM