upload file from client

how i do asp program that upload file
from cleint "User" to save it the Server
thanx for replay
hussin14Asked:
Who is Participating?
 
Chandramouli kConnect With a Mentor ArchitectCommented:
try using ftp componet which u can access it from ASP pages. (similar to mail componet).

http://www.visualmart.com/comdcom/ftp.asp

http://www.rainfall.com/coding/kftp.htm

http://www.aspin.com/home/components/internet/ftp 
(u can find free ActiveX/Com object here)

ALL THE BEST
KCM.
0
 
chops123Commented:
Download this very good free component from here:

http://www.coatingtechnology.net/Code-lib/coms/unzipped/ASPSimpleUpload/ASPSimpleUpload.dll

Example is here:

http://www.coatingtechnology.net/Code-lib/coms/unzipped/ASPSimpleUpload/Docs/

When uploading to a specific folder,the permissions to that folder should be set to Read/Write

Rgds
KC
0
 
chops123Commented:
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ZvikaCommented:
A free and simple to use upload component:
http://www.dundas.com/subFrame.asp?products/asp/upload/index.asp
0
 
webwomanCommented:
Just to clarify...
The user has to select the file. You can't. But the upload components (of some kind) are needed for the server to accept the uploaded file.
0
 
chops123Commented:
webwoman... just a friendly comment !

whenever i see a comment added by you,i always get reminded of spiderwoman.. donno why ?? ;-)

Rgds
KC
0
 
mgfranzCommented:
Assuming you have control of the server and the components that get installed, there are a number of really good free Upload components available.  I like ASPSimpleUpload but another good one is ABCUpload, both are free.

If you do not have control of the server, like it's hosted by someone else, chances are good that there is a component already installed.  

I use ASPSimpleUpload at both home and with my hosting company, the upload code looks like this;

<%@ LANGUAGE = "VBScript" %>

<%
Dim upl, NewFileName, theSku

Set upl = Server.CreateObject("ASPSimpleUpload.Upload")

If Len(upl.Form("File1")) > 0 Then
     theFileName = upl.ExtractFileName(upl.Form("File1"))
     fileExt = UCase(upl.ExtractFileExt(theFileName))
     NewFileName = "../images/" & theFileName
          If ((fileExt = ".GIF") Or (fileExt = ".JPG")) Then
               upl.SaveToWeb "File1", NewFileName
               Response.Write "Image Uploaded Successfully"
          Else
               Response.Write("There was an error saving the file to disk.")
          End If
End If
%>

<html>
<head>
<title>Upload Image</title>
<link REL="STYLESHEET" HREF="../class/all.css" TYPE="text/css">
</head>
<body>
<form method="POST" action="imageup.asp" enctype="multipart/form-data">
<table cellpadding=10 cellspacing=0 border=0>
     <tr>
          <td>Select a file to upload: <input type="file" name="File1" size="25"><p><input type="submit" name="submit" value="Upload Now"></td>
     </tr>
</table>
</form>
</body>
</html>

0
 
ksenthilrajCommented:
Hi,

Use the following class to upload file from client to server..

This code is available in www.asp101.com
1)after save this file in upload.asp
2)include this file in a file where you have to create instance of this class.. upload the file using this properties.
3) Using this class you can get the name of the file uploaded,type of the file uploaded and size of the file also you can get..

<%
Class FileUploader
      Public  Files
      Private mcolFormElem

      Private Sub Class_Initialize()
            Set Files = Server.CreateObject("Scripting.Dictionary")
            Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(Files) Then
                  Files.RemoveAll()
                  Set Files = Nothing
            End If
            If IsObject(mcolFormElem) Then
                  mcolFormElem.RemoveAll()
                  Set mcolFormElem = Nothing
            End If
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
      End Property

      Public Default Sub Upload()
            Dim biData, sInputName
            Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
            Dim nPosFile, nPosBound

            biData = Request.BinaryRead(Request.TotalBytes)
            nPosBegin = 1
            nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
            
            If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
             
            vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
            nDataBoundPos = InstrB(1, biData, vDataBounds)
            
            Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
                  
                  nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
                  nPos = InstrB(nPos, biData, CByteString("name="))
                  nPosBegin = nPos + 6
                  nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
                  sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
                  nPosBound = InstrB(nPosEnd, biData, vDataBounds)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile, sFileName
                        Set oUploadFile = New UploadedFile
                        
                        nPosBegin = nPosFile + 10
                        nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
                        sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))

                        nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
                        nPosBegin = nPos + 14
                        nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                        
                        oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        
                        nPosBegin = nPosEnd+4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                        
                        If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
                  Else
                        nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                        nPosBegin = nPos + 4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  End If

                  nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
            Loop
      End Sub


      Private Function CByteString(sString)
            Dim nIndex
            For nIndex = 1 to Len(sString)
               CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function CWideString(bsString)
            Dim nIndex
            CWideString =""
            For nIndex = 1 to LenB(bsString)
               CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public FileName
      Public FileData
      
      Public Property Get FileSize()
            FileSize = LenB(FileData)
      End Property

      Public Sub SaveToDisk(sPath)
            Dim oFS, oFile
            Dim nIndex
      
            If sPath = "" Or FileName = "" Then Exit Sub
            If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
      
            Set oFS = Server.CreateObject("Scripting.FileSystemObject")
            If Not oFS.FolderExists(sPath) Then Exit Sub
            
            Set oFile = oFS.CreateTextFile(sPath & FileName, True)
            
            For nIndex = 1 to LenB(FileData)
                oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
            Next

            oFile.Close
      End Sub
      
      Public Sub SaveToDatabase(ByRef oField)
            If LenB(FileData) = 0 Then Exit Sub
            
            If IsObject(oField) Then
                  oField.AppendChunk FileData
            End If
      End Sub

End Class
%>
0
 
ksenthilrajCommented:
Hi,

With out any component, this simple class is much useful for the file upload from client to server using http upload.

After including the class following is the simple method to upload..

Dim Uploader, File
     Set Uploader = New FileUploader
     Uploader.Upload()
       If Uploader.Files.Count = 0

Hope this help..

Cheers..
0
 
WakieCommented:
It appears this question has been abandoned.

I will leave a recommendation in the Cleanup topic area that this question will be:

- Question PAQ'd and points points to kcm76 -

Please leave any comments here within the next seven days.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Wakie,
EE Cleanup Volunteer.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.