By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,086 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,086 IT Pros & Developers. It's quick & easy.

I need Help

P: n/a
I am writing this code for file upload in asp 3.0 on my webpage........
It is working on local system but when i want to upload an image on my
website from client machine it is not working .......

can somebody help me

<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<%

'NOTE - YOU MUST HAVE VBSCRIPT v5.0 INSTALLED ON YOUR WEB SERVER
' FOR THIS LIBRARY TO FUNCTION CORRECTLY. YOU CAN OBTAIN IT
' FREE FROM MICROSOFT WHEN YOU INSTALL INTERNET EXPLORER 5.0
' OR LATER.
' Create the FileUploader
Dim Uploader, File, Rs
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

'******************************************
' Use [FileUploader object].Form to access
' additional form variables submitted with
' the file upload(s). (used below)
'******************************************
Response.Write "<b>Thank you for your upload " &
Uploader.Form("fullname") & "</b><br>"

' Check if any files were uploaded
If Uploader.Files.Count = 0 Then
Response.Write "File(s) not uploaded."
Else
' Loop through the uploaded files
For Each File In Uploader.Files.Items

' Check where the user wants to save the file
If Uploader.Form("saveto") = "disk" Then

' Save the file
File.SaveToDisk "E:\upload"
ElseIf Uploader.Form("saveto") = "database" Then

dim connection
dim sSQL, sConnString

sSQL = "INSERT INTO MyUploadTable (filename, filesize,
contenttype)VALUES('"&File.FileName&"','"&File.Fil eSize&"','"&File.ContentType&"')"
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("emails.mdb")
Set connection = Server.CreateObject("ADODB.Connection")

connection.Open(sConnString)
connection.execute(sSQL)

response.write "The data was inserted successfully."
Connection.Close
Set Connection = Nothing
End If

' Output the file details to the browser
Response.Write "File Uploaded: " & File.FileName & "<br>"
Response.Write "Size: " & File.FileSize & " bytes<br>"
Response.Write "Type: " & File.ContentType & "<br><br>"
Next
End If

%>

Jun 11 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Rizwan wrote on 11 jun 2006 in microsoft.public.inetserver.asp.general:
I am writing this code for file upload in asp 3.0 on my
webpage........ It is working on local system but when i want to
upload an image on my website from client machine it is not working
.......
Please define "not working", give error texts and erro row numbers, etc
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
How should we know what this "upload.asp" is?
Is it in the present directory?
<%
'NOTE - YOU MUST HAVE VBSCRIPT v5.0 INSTALLED ON YOUR WEB SERVER
[> I am writing this code]

Did you really write that to yourself??????????
Or are you just copying and pasting code you do not understand?
' FOR THIS LIBRARY TO FUNCTION CORRECTLY. YOU CAN OBTAIN IT
' FREE FROM MICROSOFT WHEN YOU INSTALL INTERNET EXPLORER 5.0
' OR LATER.
What library and in what directory?
' Create the FileUploader
Dim Uploader, File, Rs
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

'******************************************
' Use [FileUploader object].Form to access
' additional form variables submitted with
' the file upload(s). (used below)
'******************************************
Response.Write "<b>Thank you for your upload " &
Uploader.Form("fullname") & "</b><br>"

' Check if any files were uploaded
If Uploader.Files.Count = 0 Then
Response.Write "File(s) not uploaded."
Else
' Loop through the uploaded files
For Each File In Uploader.Files.Items

' Check where the user wants to save the file
If Uploader.Form("saveto") = "disk" Then
Which of the "If"-choices is "not working"?

' Save the file
File.SaveToDisk "E:\upload"
Has your website an ASP accessable E:\ ??
What is this File.SaveToDisk function ???

ElseIf Uploader.Form("saveto") = "database" Then

dim connection
dim sSQL, sConnString

sSQL = "INSERT INTO MyUploadTable (filename, filesize,
contenttype)VALUES('"&File.FileName&"','"&File.Fil eSize&"','"&File.Cont
entType&"')" sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("emails.mdb")
Has your current directory writing rights?
Set connection = Server.CreateObject("ADODB.Connection")

connection.Open(sConnString)
connection.execute(sSQL)

response.write "The data was inserted successfully."
Connection.Close
Set Connection = Nothing
End If

' Output the file details to the browser
Response.Write "File Uploaded: " & File.FileName & "<br>"
Response.Write "Size: " & File.FileSize & " bytes<br>"
Response.Write "Type: " & File.ContentType & "<br><br>"
Next
End If

%>


Programming is writing snd testing little titbits of code at a time
in your operating environment.

Wile you may be lucky to have a functioning code on your local
testmachine working imediately on the web real web server, as a rule you
will need to do this process of testing [again] on that real live machine
where the settings are often far different from the first.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jun 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.