Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload file in update form 1

Status
Not open for further replies.

d0nny

IS-IT--Management
Dec 18, 2005
278
GB

OK, another conundrum!

I have built a very simply CMS for my mate. Its the same stuff I was asking about previously, so a website which lists all her products.
What I want to do is get her to start populating the database with her products, so things like title, decription, product code, price and also an image.

So getting the input form sorted out for the 'text' entries is fine, but how can I add an upload section to this form so it updates the table too?

I'll be storing the images in a central folder (rather than in the database) and the database field will hold the location of the image file. Does that make sense?

I can do an upload form easily and I can do an add form too, but puting them together is my challenge.
 
Just stick them both on the same page, with the file input selector in the same form as the text input. Then make the action of that form point to a processing form (no visual output) which will do the ftp upload and (if the upload was successful) process the rest of the inputs. Test for success and either return to the input form or return appropriate message.

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
NO FTP upload required. a normal form can handle a file upload just fine. just use the <input type=file> element and your processing script should be able to receive the file in the $_FILES variable upon submission.

If you can do them apart you can do them together.

If you need to check for the correct uploading of the file before processing the rest of the form, then do that first from the $_FILES variable, and then proceed to the rest of the code.

You can use the move_uploaded_file() [/LINK]function to put the file in the folder you want it, and then place the final path into a variable to sue in your update query later in your code.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 

vacunita - many thanks.
I'm using all of the suggestions for file upload via another form, so I suppose I just use all of this code in a combined form.

Many thanks ...
 
Yup. That's correct.

You may need to add a conditional statement to check for the proper upload of the file if you need to, but other than that, whatever handles the file upload can do so in the same script.

Also make sure your pieces of code don't set variables that may be used by the other piece of code. Or make sure they are set to whatever they need to be before they get used.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top