Welcome Guest, Not a member yet? Register   Sign In
Image and record, chicken and the egg, which one comes first?
#1

[eluser]rogierb[/eluser]
Here's the situation.Im converting an old system into CI. This means having to do with some poor decissions made a decade ago. Like images.

In the old system the code checks if images exists on disk. The name is the record id of a specifc table and a number. So we have 123.1.jpeg and 123.2.jpg etc.

I want a reference in the database. This is not a problem.
The problem is error handling while uploading.

I need a record_id before I can store the images. The validation is already completed succesfully or else I wouldnt be able to safe the record.
So how do I get any image upload errors back into the form?

Normally I would redirect to an edit form. This is not possible since the edit form is different to the add form.


Any thoughts as to how resolve this?
#2

[eluser]PhilTem[/eluser]
What kind of data do you store in your table?

I was thinking about: You can create a table row before even showing the upload form. This way you will have a record_id before there is any file uploaded so you will basically only do edits on the row data not an insert.

Does this sound like a good solution for you?
#3

[eluser]lewisp[/eluser]
I don't know how easily you could adopt a new naming scheme, but you could generate a unique hash before inserting anything and use that as the ID (or in a new field) rather than using autoID.
#4

[eluser]rogierb[/eluser]
well... this table is not using a incremented ID but rather a random number between 1000.000 and 100.0000.0000.

When we are done with the record it is deleted and the number is recycled (Dont ask me why, its not my solution:-) )
Because the entire system revolves around this solution I cannot change the scheme.

The data stored in the table is like car info (like a car buying/selling website)

Because of the number recycling I cannot easily create an empty row.

Thank you for your input, the new row idea i like.




Theme © iAndrew 2016 - Forum software by © MyBB