Re: Error handling with multiple file uploads and sql
| From: | Justin French | Date: | Mon, 06 Jan 2003 11:39:27 +0000 |
| Subject: | Re: Error handling with multiple file uploads and sql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130384@lists.php.net to get a copy of this message | ||
Why not split it into 2 forms? insert, then attach pictures to the record.
Otherwise, decide what's the key issue (imho the a record can exist without
pics, but not vice-versa), and focus on that first.
Justin
on 06/01/03 10:15 PM, Jim (jimyt@yahoo.com) wrote:
> Hi,
>
> I have the following scenario:
>
> A user can login to my website (so I know their ID) and create a new 'item
> record' through a form. This item may have up to 10 images uploaded with it
> (pictures of the item). The structure of my DB is a main 'Items' table
> holding textual description/price/location information of the item and
> another table 'Pictures' holding information on each image uploaded. My
> problem is how to handle an error if something goes wrong i.e. sql insert
> fails or the file copy() fails.
>
> What I don't want to happen is for the 'Items' record to be created and then
> 1 or more files fail to upload. So I thought, I'll upload the files first,
> but the problem with this is that in the 'Pictures' table I have to enter an
> 'ItemID' field obviously to link the pictures to the item, but the ID of the
> item isn't known as it hasn't been created yet. Ahhhhhh!!
>
> My next thought was to upload the files first, then insert the 'Items'
> record, then insert the multiple 'Pictures' records.....I figure if the
> 'Items' insert works, the likelihood is that the 'Pictures' inserts will
> too.
>
> How does this sound?
>
> Thanks for any input.
>
> Jim.
>