I've looked all over and have basically found the same code for this issue, but it doesn't work for me. I'm not a real programmer, more of a graphic artist who has had to learn stuff, so it is hard to figure this out.

I have a form. In the form there is an upload file code. I want to have the user click that, select the image he wants to put on the site (in a folder called 'pix') and have the name of the file written to my database (into a field called 'photo').

I simply can not figure out how to make the code I keep finding all over work for me. I rely on Dreamweaver for a lot of my PHP. Anyway, here is the entire page. How do I do this? I'm pulling my hair out.

It looks like you have the code for logging the form info in the database...is that working? ...your just not able to handle the upload?

10-22-2012, 05:10 PM

mightyhokie

when i fill out the form and select the image to upload it IS uploading that image. What i need now is for it to write the name of the image in the database for later reference. It is driving me crazy. I have tried half a dozen techniques (all of which are very similar) but no joy. Here is the working code for the add.php page, as well as the update.php, minus the ability for it write the name to the DB. If you could tell me how to make it work i would be very grateful. Please help a brother out! =D

Sorry for the delay in my response. Usually i get an email saying a post has been answered but not this time. Anyway, yes, it is writing all the data to the database except for the name of the file it is uploading. so the blogID, date, title, content all upload to the database. photo just comes up NULL. I have tried several techniques I got off the web but I don't have enough php understanding to apply it to my code.

10-23-2012, 08:55 AM

criterion9

The name is included as part of the upload array...

$_FILES['photo']['name']

10-23-2012, 09:08 AM

mightyhokie

i don't know what that means and i don't know what to change. im not a total novice but I do rely on DW to write a lot of the PHP code. What am I supposed to change to make it work?

criterion9,
I know what a variable is. I understand that. But you are coming at the problem from the mindset of a programmer, and I'm coming at it from the mind of an artist. Want me to show you how to be creative? Fine, here, I'll use your technique...'think differently'. There you go. I've helped you.

10-23-2012, 10:32 AM

mightyhokie

okay, here is the 'upload a file and write to mySQL' code that I have been trying to fuse with my current code. My current code WORKS in the sense that it writes all the data (blogID, date, content, title) to the correct fields in the database. it does upload the file to the correct folder. id does NOT write the name of the uploaded file to the database.

Basically a very similar thing needs to happen based on your add script. You need to add the name field into your query and move your file upload/name variable assignment portion above the query so it can be included: