Jump to content

Upload image, and add path to MySQL database


TechThat

Recommended Posts

Hello freaks!

 

Im new to this forum, but im not all that new to PHP and MySQL.

Although there's been some years since the last time I used it, so don't go all freaky on me if I dont do this right ;)

 

Let's go on-topic:

Im in progress of making an internal web-page for me and my colleagues to make things a bit easier for us.

I am making an database of our different projects, and I need some help with the input form - as I need to upload an image to the server, and store the path in the MySQL database.

 

In my input form, I need to store information from text fields, and I need to upload an image to the server and store the path in the database.

Before I can even start to code this (although I have coded the input forum without the upload), I need to know what would be the best way to do this.

I guess there are several ways.. What would the expert do (That's you right?)?

 

Should I have the information input, and image upload in the same form, or should I make a second form (maybe on a different page) for the upload?

Is it necessary with two tables, one for the info and one for the image path, and then tie them together with the imageID, or is it fine to use just one table?

 

Any thoughts would be appreciated!

 

<!-- TechThat -->

Link to comment
Share on other sites

well i for one wouldn't bother reinventing the wheel

 

have a look at

http://www.uploadify.com/

and

http://www.verot.net/php_class_upload.htm

 

uploadify is jquery

it needs a 'script' to do the actual uploading,

i use a file i call upload.php

this uses the php_class_upload class to do the work, at the end of this, if the upload succeeds i put the mysql update bit

 

so, i use the jquery / uploadify bit on my main entry page

this calls upload.php to do the lifting

if the upload succeeds the database is updated with the file name

uploadify can then, via a javascript callback, refresh part of your page with the newly uploaded image

 

this lot takes a little understanding of using jquery/javascript and php together

but you end up with a nice reactive file upload

 

oh, and i'd use two tables as you suggest

if in the future your going to need two or more images for the info, your good to go

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.