Solved

upload file from client

Posted on 2002-06-03
10
564 Views
Last Modified: 2012-08-13
how i do asp program that upload file
from cleint "User" to save it the Server
thanx for replay
0
Comment
Question by:hussin14
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 5

Accepted Solution

by:
kcm76 earned 100 total points
ID: 7050701
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
 
LVL 2

Expert Comment

by:chops123
ID: 7050709
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
 
LVL 2

Expert Comment

by:chops123
ID: 7050717
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 4

Expert Comment

by:Zvika
ID: 7050852
A free and simple to use upload component:
http://www.dundas.com/subFrame.asp?products/asp/upload/index.asp
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7050909
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
 
LVL 2

Expert Comment

by:chops123
ID: 7050924
webwoman... just a friendly comment !

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

Rgds
KC
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 7051384
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
 
LVL 1

Expert Comment

by:ksenthilraj
ID: 7053444
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
 
LVL 1

Expert Comment

by:ksenthilraj
ID: 7053449
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
 
LVL 4

Expert Comment

by:Wakie
ID: 9142907
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question