Skip to main content
Inspiring
August 27, 2006
Question

Question about adapting an update form for image uploads

  • August 27, 2006
  • 19 replies
  • 1806 views
I have a form that updates a recordset in a MySQL database. Vanilla stuff,
really.

I want to add the following capabilities to the form -

1. Upload an image
2. Resize the image according to preset maxwidth/height values, and save it
with the uploaded name
3. Resize it to a thumbnail and save that with a modification of the
uploaded name
4. Add the parent image name (and all the other fields) back to the
database for that particular record number

I know how to do #1, #2, and #3 (using GD to do this), but what I am not
sure about is a) how to adapt the existing form to do this (more than just
adding an image field), and b) what order to do things in.

I think I have to add 'enctype="multipart/form-data"' to the <form> tag, is
that right? Will that affect any of the rest of the functionality of the
form?

Also, I'm thinking I need to upload the image files and process them
*before* adding the data to the database - would that be the best way?

Thanks for any suggestions....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

19 replies

Inspiring
August 28, 2006
Heh - I have the file upload and the resizing and saving thing nailed. What
I am trying to sort out is how to manage the database updating for that
record....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns982D55FD646C2makowiecatnycapdotrE@216.104.212.96...
> On 27 Aug 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> I'm knee deep in PHP on this one, Jules!
>
> I had a passing thought on this:
> - If you're on a PHP5 server, the object oriented stuff is significantly
> enhanced. Maybe somebody has already written a file upload class?
> - Even if you're not, Pear ( http://pear.php.net/) has a file upload
> class. http://pear.php.net/HTTP_Upload
>
> I haven't explored this stuff in any depth, but it has the potential to
> make something like this easier. (You needed more research to do,
> right?)
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Inspiring
August 28, 2006
On 27 Aug 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> I'm knee deep in PHP on this one, Jules!

I had a passing thought on this:
- If you're on a PHP5 server, the object oriented stuff is significantly
enhanced. Maybe somebody has already written a file upload class?
- Even if you're not, Pear ( http://pear.php.net/) has a file upload
class. http://pear.php.net/HTTP_Upload

I haven't explored this stuff in any depth, but it has the potential to
make something like this easier. (You needed more research to do,
right?)

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Inspiring
August 28, 2006
Murray *ACE* wrote:
> GD creates a temp file when it resizes - where does that file get saved?

Wherever you tell PHP to save it. Otherwise it gets thrown away.

> So, I'm thinking my second scenario is the best -

As I said before, my scenario is revealed in a new book due out in
November. Although it's quite straightforward, there are quite a lot of
steps involved. See my reply offlist.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
August 28, 2006
GD creates a temp file when it resizes - where does that file get saved?

> and save the filenames in a database.

There would only be a single filename - the thumb name is generated
programmatically (e.g., fileTH.jpg).

So, I'm thinking my second scenario is the best -

1. Select the record to update and get the update screen
2. Click on "New Image" if the image is to be updated
3. If the image is not going to be updated, just accept changes and update
the database from this page.
3b. If the image is to be updated, go to a new page that just updates the
image (with all the GD stuff), enters the image name in the database, and
passes the record# back to the update page for further updates.


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:ecud05$mun$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> I'm knee deep in PHP on this one, Jules!
>
> It's fairly easy in PHP. You just need to get things done in the right
> order. Upload the image, create GD image resources to handle the original
> and the resized image, manipulate them and move them to their target
> locations, destroy the image resources, and save the filenames in a
> database.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Inspiring
August 28, 2006
Murray *ACE* wrote:
> I'm knee deep in PHP on this one, Jules!

It's fairly easy in PHP. You just need to get things done in the right
order. Upload the image, create GD image resources to handle the
original and the resized image, manipulate them and move them to their
target locations, destroy the image resources, and save the filenames in
a database.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
August 28, 2006
Yeah - that's how I'll do it, I think....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns982CB27CB6DBmakowiecatnycapdotrE@216.104.212.96...
> On 27 Aug 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> I've been through that page a number of times - in fact the upload
>> markup I will use is what is shown in example 1 - it works very
>> well. The trick is to sequence everything.
>>
>> I believe what I will do is to have an update page that shows the
>> database information for the selected record, and shows the
>> thumbnail for the image. This page will have an update button that
>> will update the database with any edits you make.
>>
>> Next to the displayed image, there will be a button saying "select
>> new image" or something. Clicking that button will take you to a
>> new page, allowing you to browse to and select a new image. When
>> you submit that page, the image will be uploaded, resized into both
>> the page's max size, and the thumb size, and the new image's name
>> will be entered into the database. You will then be redirected back
>> to the original update page, which will show the new image.
>>
>> Does that make sense? Does it seem like a logical flow?
>
> Sounds logical to me. Your biggest problem is going to be keeping track
> of where you are and what goes what where. Sessions are your friend.
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Inspiring
August 28, 2006
I'm knee deep in PHP on this one, Jules!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Julian Roberts" <nospam@charon.co.uk> wrote in message
news:ect6hj$cn8$1@forums.macromedia.com...
> This is fairly straightforward in ASP.NET. The enctype attribute is
> automatically handled. You'd then store the file name in the database and
> use HTTP handlers to resize images on the fly.
>
> --
> Jules
> http://www.charon.co.uk/charoncart
> Charon Cart 3
> Shopping Cart Extension for Dreamweaver MX/MX 2004
>
>
>


Inspiring
August 27, 2006
This is fairly straightforward in ASP.NET. The enctype attribute is
automatically handled. You'd then store the file name in the database and
use HTTP handlers to resize images on the fly.

--
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004



Inspiring
August 27, 2006
On 27 Aug 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> I've been through that page a number of times - in fact the upload
> markup I will use is what is shown in example 1 - it works very
> well. The trick is to sequence everything.
>
> I believe what I will do is to have an update page that shows the
> database information for the selected record, and shows the
> thumbnail for the image. This page will have an update button that
> will update the database with any edits you make.
>
> Next to the displayed image, there will be a button saying "select
> new image" or something. Clicking that button will take you to a
> new page, allowing you to browse to and select a new image. When
> you submit that page, the image will be uploaded, resized into both
> the page's max size, and the thumb size, and the new image's name
> will be entered into the database. You will then be redirected back
> to the original update page, which will show the new image.
>
> Does that make sense? Does it seem like a logical flow?

Sounds logical to me. Your biggest problem is going to be keeping track
of where you are and what goes what where. Sessions are your friend.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Inspiring
August 27, 2006
hehehe, and no luck till then, I guess! ;o)