|
-
Jul 16th, 2001, 12:27 AM
#1
Thread Starter
New Member
Storing a graphic to a database via an ASP
Urgent query on VBscripting and databases..
Ive got an asp that allows user to enter certain records into a ms access database. Pretty standard stuff. However, i also have to allow these users to store graphic files along with their records.
Its like this.. On my website, a user has an equipment for sale and enters its description and price so that it can be displayed to other users (via a table display of the equipment records in my database).
How do i also allow other users to see a picture of the equipment that the original user had posted? Is there a way to link a record in a database (ms access) to a graphic file (*.bmp) ? Im totally new at all this and i need all the help i can get
*i hope i dont sound too confusing*
-
Jul 16th, 2001, 03:05 AM
#2
Lively Member
Hi
this is easy but you got to do few things for that.
1. in you database add a field for graphics file name.
2. add a file field in your form from which user can upload picture.
when ever a user submit this form all the information like his name ..... , graphics file what ever (jpeg, gif, or bmp) will be submitted in your databse. like
the graphics file will store in a specif folder (which you got to define).
and also the name of this graphics file will add in your database with the user information.
i think it help.
but if you have still some problem and you want complete code for that then let me know.
Adeel Ahmed
-
Jul 17th, 2001, 10:15 PM
#3
Thread Starter
New Member
Thanks for replying :)
Ok i get the idea.. So i store the address of the stored graphic in a database and store the graphics in a specified folder.. How do u write the code for the Uploading?
The complete code would be really helpful, thanks cuz im still stuck on it..
-
Jul 18th, 2001, 06:46 AM
#4
Lively Member
Hi
for uploading a file using ASP u got to use a third party software
plz visit http://www.softartisans.com
for free evaluation softwares
i've attached a file by which u can get a better idea abt How u can retrieve a picture from database with the userinfor who has uploaded it.
Adeel Ahmed
-
Jul 21st, 2001, 06:05 AM
#5
Thread Starter
New Member
Thanks!
Thank you so much for your help
Though is there a way not to do it without unsing the uploading software from softartisans?
-
Jul 21st, 2001, 09:48 PM
#6
You can upload file to the specific folder at the server using pure asp code .. no third party control is needed. If you need it, i can send you the code.
-
Jul 22nd, 2001, 03:42 AM
#7
Lively Member
hiya
Kornifica
you can absolutely upload a file without using any 3rd pary tool
visit this url to get whole code!!!
http://msdn.microsoft.com/library/en...asp?frame=true
Adeel Ahmed
-
Jul 23rd, 2001, 01:06 PM
#8
Thread Starter
New Member
it has to be purely ASp
thanks guys for the help
mahfooz.. can i take a look at your code too?
-
Jul 23rd, 2001, 03:26 PM
#9
Here is a link to an ASP upload script:
Pure ASP Upload Script
-
Jul 23rd, 2001, 06:38 PM
#10
PowerPoster
man, people ask this question all the time...we need a faq
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Jul 23rd, 2001, 07:47 PM
#11
Fanatic Member
here, you can use this pure ASP code to upload files.... I got this from one of the articles in a vb website (sorry i forgot where i get it)... it works... i have already tried it!
On Error GoTo Hell
Hell:
Kill Me
Food For Thought:
- Do not judge a book... if you're not a judge!

-
Jul 24th, 2001, 09:57 AM
#12
Hyperactive Member
Uhhhhhhmmmmmmm.... where's the library?
-
Jul 24th, 2001, 10:16 AM
#13
Frenzied Member
here's one that works for sure
i am using it in 3 site at the moment
jus don't forget to your form to
enctype="multipart/form-data" ACTION="upLoad.asp" METHOD="POST"
and another thing, with this code, you can use request(""),
because in vbscrpt after you use Request.BinaryRead
you can user the request collection no more!!
here the code for upload
Code:
<!--#INCLUDE FILE="uploadFunctions.asp" -->
<%
Dim tBytes
Dim binData
Dim Dict
Dim fileName
Dim fso
Dim fsoFile
Dim binaryFileContent
Dim i
tBytes = Request.TotalBytes
binData = Request.BinaryRead(tBytes)
Set Dict = BuildUploadRequest(binData)
fileName = Dict.Item("fName").Item("FileName")
binaryFileContent = Dict.Item("fName").Item("Value")
fileName = ParseFileFromPath(fileName)
picName=fileName
fileName = Server.MapPath("../images/shirt/big/" & fileName)
session("resumePath")=fileName
'==constructing the filepath of the root
' on server
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fsoFile = fso.CreateTextFile(fileName, True)
For i = 1 To LenB(binaryFileContent)
fsoFile.Write Chr(AscB(MidB(binaryFileContent, i, 1)))
Next
fsoFile.Close
Set fso = Nothing
'====== You are done!
'====== You should have read/write permi
' ssions for the server directory where yo
' u save your file
here's the upload functions
Code:
<%
function getString(StringBin)
getString =""
For intCount = 1 To LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End function
function getByteString(StringStr)
For i = 1 To Len(StringStr)
char = Mid(StringStr, i, 1)
getByteString = getByteString & chrB(AscB(char))
Next
End function
function BuildUploadRequest(RequestBin)
Dim scrDict
Set scrDict = Server.CreateObject("Scripting.Dictionary")
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Pos = InstrB(BoundaryPos,RequestBin, getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile=InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
if PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End if
UploadControl.Add "Value" , Value
scrDict.Add Name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
Set BuildUploadRequest = scrDict
Set scrDict = Nothing
End function
function ParseFileFromPath(iStr)
Dim tPos
tPos = InStrRev(iStr, "\")
if tPos = 0 Or IsNull(tPos) Then
ParseFileFromPath = iStr
Exit function
End if
ParseFileFromPath = Right(iStr, Len(iStr) - tPos)
End function
%>
-
Jul 24th, 2001, 10:24 AM
#14
Very bottom of the article:
"You can download the library and sample files here"
-
Jul 24th, 2001, 10:33 AM
#15
Hyperactive Member
I know, coz I have downloaded it, but the zip does not contain any library files in it. Only asp, txt, and htm files. no dll, no nottin.
Have I perhaps downloaded the wrong file? Heheheh. Maybe.
But no, I'm sure that its the right file. Yes. it must be, coz, it is the same url you gave me.
-
Jul 24th, 2001, 10:34 AM
#16
It is a pure ASP script, no dlls.
-
Jul 24th, 2001, 01:05 PM
#17
PowerPoster
thanks for that upload, i have been wanting one of those for a long time
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Jul 24th, 2001, 03:54 PM
#18
Hyperactive Member
You all should go to stardeveloper.com/databases.asp
This dude has a shtload of cool examples including one that uploads the picture directly to the database.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Jul 24th, 2001, 03:57 PM
#19
Personally I don't feel that images should be stored directly in the database. I prefer to store the path to the image, then store the image on the file server.
I will take a look at the site though, always looking for new information
-
Jul 26th, 2001, 09:20 PM
#20
Hyperactive Member
Can the picture reside in the web server by itself or must I hace a file server?
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Aug 1st, 2001, 02:04 PM
#21
PowerPoster
ok I have tried the 2 downloads that are posted here and all that happens when I try to upload on my local machine is that the page hangs...
any ideas?
-
Aug 1st, 2001, 02:13 PM
#22
Frenzied Member
mine works jesus4u!!change
fileName = Server.MapPath("../images/shirt/big/" & fileName)
to a valid path
that is the one i use on our site to upload resume
-
Aug 1st, 2001, 02:16 PM
#23
PowerPoster
ok I didn't use yours cause I am a simple man and I didn't see the interface but I will give it a go!
-
Aug 1st, 2001, 02:27 PM
#24
PowerPoster
sebs is ur code posting to itself or do I create another page?
-
Aug 1st, 2001, 06:03 PM
#25
Frenzied Member
well,
in total there is 3 pages,
one with your form(with the upload button)
one that your form is submitted to,
and a third one(asp functions) that is included in the previous one,
so you only see one,
but if you want , you can make it submit to itself, no problemo!
hope it help you, if you have any problem just ask,
cause it work perfectly,i use it in 3 site at this moment!!
see ya!
-
Aug 2nd, 2001, 07:39 AM
#26
PowerPoster
-
Aug 3rd, 2001, 01:16 AM
#27
Hyperactive Member
OK I want to do what is said above and have the picture in a folder but the path in a database. If the visitor uploads the picture, how do I 'grab' the filename and store in in the database?
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Aug 3rd, 2001, 07:11 AM
#28
Frenzied Member
if you take my mine,
this line is your filename
fileName = ParseFileFromPath(fileName)
here the file path, you can put your own, just make the folder before
fileName = Server.MapPath("../images/shirt/big/" & fileName)
-
Aug 4th, 2001, 05:20 PM
#29
Hyperactive Member
No, what I meant was, that the picture is stored on a folder but I want the name of the picture, for example "pic23.gif" to be stored in a database field, so then I can reference to it.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Aug 7th, 2001, 03:55 AM
#30
Frenzied Member
don't forget to put this to your form
enctype="multipart/form-data"
and it should work
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|