 |
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4  | This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040 |
Please indicate which version of the book you are using when posting questions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 17th, 2005, 02:54 PM
|
|
Authorized User
|
|
Join Date: Oct 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Upload Images to database
Hey all! I have been working on a site for a bit of time now, itâs a type of profile based site, however there is one problem I am stuck on and cannot get it to work! Sorry if this seems a bit long winded but I am stuck and would love anybody that could help me!lol! I have been using the book, using the recordsets etc to alow users to set up their profiles, but I really want to let the users upload images to their profile, but cannot workout how, and I am wondering if there is a simple change which I can do to what I have been doing to allow this. ( One thing I have been doing is I have been doing them in php with a mysql database, however the method in using recordsets seems to be the same).
I will explain what I have tried to do,(please donât mock me if it is totally wrong!!).
OK, so I have added a recordset and used the insert/record insertion form, then modified it so that I have an upload item on the photo database value( I have made the mysql record a Blob for the photo). Then on the display page I just try to display the photo (along with the other info) by just dragging the items across from the bindings panelâ¦and it doesnât work and I am pretty sure the photo file doesnât even get uploaded into the database. If you can give me any pointers on doing what I need to do please feel free, I would be extremely greatful for your help!!
Mike
|
|

December 18th, 2005, 07:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Mike,
Storing the uploaded files in the database is usually not considered a good practice for the following reasons:
1. It's slow.
It's much slower to get the files from the database as opposed to getting them from disk directly. This also applies to caching etc
2. Difficult to backup.
Depending on the files you store, your database may become hard to backup. For example, a 2Gig movie clip doesn't change, so there is no need to back it up every day. However, once that clip is inside the database, you do need to back it up daily as the entire database will have changed
3. Difficult to use and program.
With the uploaded files in a database, you can't reference the files from your ASP pages directly. You need a separate file that, say, expects the ID of an uploaded file in the database and then "materializes" that file.
That said, there are circumstances where saving the files in the database solves a lot of problems. It's just something you need to consider very carefully.
So, what to do next then? It's probably better to store only a reference to the file in your database. So, let's say you uploaded a photo. You save the file somewhere (using a third party component like ASP Upload) and then all you store in the database is the virtual (or physical) path to the image. E.g. "/Images/Employees/Mike.jpg"
Then when you need to display the image, you can do something like:
<img src="<%=MyRecordset("ImageUrl")%>" alt="<%=MyRecordset("ImageDescription")%>" />
This displays the image and sets the alt text.
Does this help?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

December 18th, 2005, 10:40 AM
|
|
Authorized User
|
|
Join Date: Oct 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar, Thanks for your help!! Yes, after doing some searching around I thought it would be a better idea to store the images outsdide of the db and just store the path to it. I have been playing round with a couple of scripts, but I cannot seem to find where they are uploading the files to!lol! It seems to be a temp folder somewhere. Would I need to use a third party component to uplaod the file? Or would I be able to use an upload item thing that i build myself?? Also I have been trying to think of what records I need in my db if all I am doing is storing the path of the image, I am thinking along the lines of, the path of the file, description, and the user id of the user who uploaded it...am I missing anything important?? Thanks again Imar!!
Mike
|
|

December 19th, 2005, 02:16 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Mike,
To upload files, you need additional software / code. If you don't want to use a component, search Google for "pure asp" and Upload. This will bring you here: http://www.asp101.com/articles/jacob/scriptupload.asp
That page explains how to use ASP only to upload files.
However, if you can use a component, that's a much better option. Most components provide a nice API enabling you to do much more than simply upload a file.
Besides the fields you mentioned, you could also save the original file name and extension, the content type of the file, and maybe the date and time it was uploaded.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

December 20th, 2005, 12:53 PM
|
|
Authorized User
|
|
Join Date: Oct 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thnka Imar, I think I have a better idea of what I need to do now! I am going home for Christmas tomorrow though, and I get told off by the family if I spend all of all my time on the computer, so think I think the next time I have a good go at this will be at the beginning of the new year, so you might here about how it is going then! Lol! I hope you have a good Christmas anyway, all the best,
Mike
|
|

December 20th, 2005, 03:49 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
You too and good luck.
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |