File Upload within a form

Is there a way to do a file upload (for a photo or PDF) within another form using PHP?
I’m trying to make a form that posts information to a database but I want to do a file upload to allow the user to upload a pdf to a column on the database as well.

Any insight?

Thanks.

Well if you want to “Upload” a file into your database, of course you need to make sure you have the correct data type (I believe it’s blob).

But YES, you can use PHP and HTML to do file uploads.

A good place to start would be http://us.php.net/features.file-upload

I know how to upload a file flat out…my question is can I upload a file with a form.
Here’s the application.

I have a form where a user can insert information into a variety of fields that will be stored into a database and then printed in a table in another section of the website…kind of acting like a CMS. I want one of the columns in that table to be a link to a PDF (different for each record). Is that possible all within this one form??

I not really sure what you are asking.

You want to upload the file on one page and display a link to the uploaded file on another?

When you talk FORM are you talking about an HTML Form (i.e. … ?) or are you talking about something different?

I have made a PHP form that takes the user’s input text and posts to the database. I have another page that is selecting all of those fields and displaying them in a table. But I want to add to that HTML form a file upload to upload a PHP document that will also be selected and printed in the calling page’s table as a link.

Can I combine the file upload scripts within the original form?

You should be able to, however, you will only be able to “Submit” one form at a time.

Okay…yeah that’s my question.

I was wondering in the processing script if I could upload and save the image (pdf) and process the form to the database within the same script.

Yes, as long as both are done with the same form (Since that is the data that gets submitted). Obviously you would need to setup your script so that it processes everything you need (the upload as well as the database information.)

gracias.

Sponsor our Newsletter | Privacy Policy | Terms of Service