473,725 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File uploading to server

M P
Can you help me find an asp code that will upload a file from my PC to web
server?

Mark
Jul 19 '05 #1
4 2195

Hi Mark, hereunder code for uploading. On www.dundas.com you find a very
good FREE upload component. This component can help you renaming and saving
the uploaded files. On www.aspfaq.com you can find more components (not
free)
<%
Session("sender ")="upload. asp"
If Session("userId ")="" then Response.redire ct "login.asp"

Response.Write "<html>"

Response.Write "<header>"
Response.Write "<title>Fotoser ver HSW-MVA Upload</title>"
Response.Write "<link rel=""styleshee t"" type=""text/css""
href=""common/css.inc"">"
Response.Write "</header>"
Response.Write "<body>"

Response.Write "<form method=""POST"" EncType=""Multi part/Form-Data""
name=""album"" action=""upload 2.asp"">"
Response.Write "<table class=""button" ">"
Response.Write "<tr><td>Aanbie der</td><td>" & session("userCo mpany") &
"</td></tr>"
Response.Write "<tr><td>Refere ntie</td><td><input type=""text"" name=""ref""
size=""10""></td></tr>"
Response.Write "</table>"
Response.Write "<table width=""760"" class=""button" " style=""border: #ffffff
1 solid"">"
Response.Write "<tr><td>Versla g</td><td><input class=""button" "
type=""file"" name=""foto1"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 01</td><td><input class=""button" "
type=""file"" name=""foto2"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 02</td><td><input class=""button" "
type=""file"" name=""foto3"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 03</td><td><input class=""button" "
type=""file"" name=""foto4"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 04</td><td><input class=""button" "
type=""file"" name=""foto5"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 05</td><td><input class=""button" "
type=""file"" name=""foto6"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 06</td><td><input class=""button" "
type=""file"" name=""foto7"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 07</td><td><input class=""button" "
type=""file"" name=""foto8"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 08</td><td><input class=""button" "
type=""file"" name=""foto9"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 09</td><td><input class=""button" "
type=""file"" name=""foto10"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 10</td><td><input class=""button" "
type=""file"" name=""foto11"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 11</td><td><input class=""button" "
type=""file"" name=""foto12"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 12</td><td><input class=""button" "
type=""file"" name=""foto13"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 13</td><td><input class=""button" "
type=""file"" name=""foto14"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 14</td><td><input class=""button" "
type=""file"" name=""foto15"" size=""100""></td></tr>"
Response.Write "<tr><td>Fo to 15</td><td><input class=""button" "
type=""file"" name=""foto16"" size=""100""></td></tr>"
Response.Write "<tr><td>&n bsp</td><td><input class=""button" "
type=""submit"" value=""Upload" " name=""B1""> <input class=""button" "
type=""reset"" value=""Wissen" " name=""B2""></td></tr>"
Response.Write "</table>"
Response.Write "</form>"
Response.Write "</body></html>"
%>
Jul 19 '05 #2
This is the direct download link of Dundas.
http://aspalliance.com/dundas/default.aspx
Jul 19 '05 #3
On Tue, 3 Aug 2004 16:20:14 +0800, "M P" <ma**@textguru. ph> wrote:
Can you help me find an asp code that will upload a file from my PC to web
server?


This isn't a DB question, so I'm only answering in
microsoft.publi c.inetserver.as p.general...

FAQ:

How do I upload files from the client to the server?
http://www.aspfaq.com/show.asp?id=2189

Jeff
Jul 19 '05 #4
--- start upload.asp ---

<%
'############## ############### ############### ############### ############### #
###
'# http://www.asp101.com/articles/jacob/scriptupload.asp
'############## ############### ############### ############### ############### #
###
'
'************** *************** **********
' File: Upload.asp
' Author: Jacob "Beezle" Gilley
' Email: av***@airmail.n et
' Date: 12/07/2000
' Comments: The code for the Upload, CByteString,
' CWideString subroutines was originally
' written by Philippe Collignon...or so
' he claims. Also, I am not responsible
' for any ill effects this script may
' cause and provide this script "AS IS".
' Enjoy!
'************** *************** ***********

Class FileUploader
Public Files
Private mcolFormElem

Private Sub Class_Initializ e()
Set Files = Server.CreateOb ject("Scripting .Dictionary")
Set mcolFormElem = Server.CreateOb ject("Scripting .Dictionary")
End Sub

Private Sub Class_Terminate ()
If IsObject(Files) Then
Files.RemoveAll ()
Set Files = Nothing
End If
If IsObject(mcolFo rmElem) Then
mcolFormElem.Re moveAll()
Set mcolFormElem = Nothing
End If
End Sub

Public Property Get Form(sIndex)
Form = ""
If mcolFormElem.Ex ists(LCase(sInd ex)) Then Form =
mcolFormElem.It em(LCase(sIndex ))
End Property

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

biData = Request.BinaryR ead(Request.Tot alBytes)
nPosBegin = 1
nPosEnd = InstrB(nPosBegi n, 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(nDataBou ndPos, biData, CByteString("Co ntent-Disposition"))
nPos = InstrB(nPos, biData, CByteString("na me="))
nPosBegin = nPos + 6
nPosEnd = InstrB(nPosBegi n, biData, CByteString(Chr (34)))
sInputName = CWideString(Mid B(biData, nPosBegin, nPosEnd-nPosBegin))
nPosFile = InstrB(nDataBou ndPos, biData, CByteString("fi lename="))
nPosBound = InstrB(nPosEnd, biData, vDataBounds)

If nPosFile <> 0 And nPosFile < nPosBound Then
Dim oUploadFile, sFileName
Set oUploadFile = New UploadedFile

nPosBegin = nPosFile + 10
nPosEnd = InstrB(nPosBegi n, biData, CByteString(Chr (34)))
sFileName = CWideString(Mid B(biData, nPosBegin, nPosEnd-nPosBegin))
oUploadFile.Fil eName = Right(sFileName ,
Len(sFileName)-InStrRev(sFileN ame, "\"))

nPos = InstrB(nPosEnd, biData, CByteString("Co ntent-Type:"))
nPosBegin = nPos + 14
nPosEnd = InstrB(nPosBegi n, biData, CByteString(Chr (13)))

oUploadFile.Con tentType = CWideString(Mid B(biData, nPosBegin,
nPosEnd-nPosBegin))

nPosBegin = nPosEnd+4
nPosEnd = InstrB(nPosBegi n, biData, vDataBounds) - 2
oUploadFile.Fil eData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)

If oUploadFile.Fil eSize > 0 Then Files.Add LCase(sInputNam e),
oUploadFile
Else
nPos = InstrB(nPos, biData, CByteString(Chr (13)))
nPosBegin = nPos + 4
nPosEnd = InstrB(nPosBegi n, biData, vDataBounds) - 2
If Not mcolFormElem.Ex ists(LCase(sInp utName)) Then mcolFormElem.Ad d
LCase(sInputNam e), CWideString(Mid B(biData, nPosBegin, nPosEnd-nPosBegin))
End If

nDataBoundPos = InstrB(nDataBou ndPos + LenB(vDataBound s), biData,
vDataBounds)
Loop
End Sub

'String to byte string conversion
Private Function CByteString(sSt ring)
Dim nIndex
For nIndex = 1 to Len(sString)
CByteString = CByteString & ChrB(AscB(Mid(s String,nIndex,1 )))
Next
End Function

'Byte string to string conversion
Private Function CWideString(bsS tring)
Dim nIndex
CWideString =""
For nIndex = 1 to LenB(bsString)
CWideString = CWideString & Chr(AscB(MidB(b sString,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(sPat h)
Dim oFS, oFile
Dim nIndex

If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"

Set oFS = Server.CreateOb ject("Scripting .FileSystemObje ct")
If Not oFS.FolderExist s(sPath) Then Exit Sub

Set oFile = oFS.CreateTextF ile(sPath & FileName, True)

For nIndex = 1 to LenB(FileData)
oFile.Write Chr(AscB(MidB(F ileData,nIndex, 1)))
Next

oFile.Close
End Sub

Public Sub SaveToDatabase( ByRef oField)
If LenB(FileData) = 0 Then Exit Sub

If IsObject(oField ) Then
oField.AppendCh unk FileData
End If
End Sub

Public function binary()
binary = FileData
End function
End Class
%>

--- koniec upload.asp ---


--- start : wykorzystanie w aplikacji ----

Dim Uploader, File
Set Uploader = New FileUploader
Uploader.Upload ()

For Each File In Uploader.Files. Items
dim RS
Set RS = Server.CreateOb ject("ADODB.Rec ordset")
RS.Open "select foto from WYROBY where ID = " & admin_wyr_id,
application("sh opman") , 2, 2

File.SaveToData base RS("foto")

' Commit the changes and close
RS.Update
RS.Close
Next

--- koniec : wykorzystanie w aplikacji ----



Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2204
by: Jonathan | last post by:
Hi everyone, I have a problem with the file uploading in Asp.Net and I have read a lot on forums on this but never found an answer. Here is the problem: I know Asp.Net maximum Length for uploading a file to the server is 4Mo but I changed that maximum to about 10Mo in my web.config file : <httpRuntime executionTimeout="45" maxRequestLength="10000" useFullyQualifiedRedirectUrl="true" />
4
9716
by: Shawn Mesiatowsky | last post by:
I have an html form that accepts a file for uploading, but I wanted to create a program to automate the upload procedure. I beileive you use the Webresponse class, but I was not sure how to use this class to post a file to a specified website. In some documentation I have, it also specifies the Request Header must be: Content-type: application/octet-stream here is the web site html code: <form action=post method=post...
4
5728
by: Kenneth Keeley | last post by:
Hi, I have a page that uploads files to my server and I wish to display a "Please wait while uploading" page to the user while the file is uploading. I have been able to redirect the user once the file is finished uploading but am not sure how to do it while file is uploading. Some sample code would be welcomed with open arms. Thank You.
3
2425
by: moondaddy | last post by:
I have a simple webform where a user can upload images by using an input element of type "file". In the a button's click event in the codebehind is this code which saves the file to the server. Everything works OK. My concern is how can I be sure the user is really uploading an image and not a file with some malicious code in it. Also, can someone tell me what my security concerns are here? Here's the html: <form id="Form1"...
13
4315
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
3
5051
by: Mike Kelly | last post by:
Hi. I've built a page using standard ASP.NET 2.0 features and when I upload a large file (>20MB) to our intranet server, I get a paltry 100KB/s on our 100Mb/s LAN. Simply copying the file, I get around 7MB/s. I'm using a FileUpload control on an .aspx page, and then I'm writing the MyFileUpload.PostedFile.InputStream off to a database. What can I do to speed up this uploading? Thanks in advance
12
2905
by: SAL | last post by:
Hello, Is it possible to read a CSV from the Client, and bind my Datagrid to the data in the CSV file without uploading the file to the Server first? I have tried and in Debug mode on my workstation it works fine, but when I publish the page on our DEV server it doesn't fine the CSV file from the client. Has anyone done this before? If so, how do I do it? I'm new to ASP.net so
7
3189
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
1
541
by: King | last post by:
Hello, I would like to check to see if the file that I am uploading to my server is of type CSV. I am currently doing that with the following snippet: HttpPostedFile file = UploadBox.PostedFile; if (file.ContentType.Equals("application/vnd.excel")) { do stuff;
3
1913
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not work properly. That means the file is not uploaded to the specified location. It always executes the "else" condition in my coding. I think the problem is lieing in the specifed path which is the target path for file uploading. I could not find out...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2634
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.