Jump to content

Upload and retrieve image in database


I-AM-OBODO

Recommended Posts

hi,

i have a form that requires image to be uploaded.

i know how to store the form values in a database but i don't know how to store the image into the database.

i want the user to upload picture and preview the data provided review (including the image) before submitting to the database.

 

thanks

Link to comment
Share on other sites

Lot's of pros and cons regarding storing images in db as blob.

http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx

 

Personally, prefer to store the images in folders, with image info in the db

 

yeah. i heard a person or argue about that. but i wonder which is the best practice considering bandwidth and server load? i have seen the link you gave me and thank you very much cos i got it working, but the problem is that i dont want to download the image rather i'd like when i want i can call any data and then i will see all the info for that person and then the picture included just like entering a form for school or visa lottery.

 

thanks a great deal

Link to comment
Share on other sites

upload image - requires bandwidth and server processing

store image - require space whether its in a db as a blob or in a folder

display image from db requires bandwidth

display image from folder requires bandwidth

ease of displaying image from db - for me TOUGH

ease of displaying image from folder - NO BRAINER

you decide.

 

Link to comment
Share on other sites

Images are files, and the filesystem is well suited for storing files, whereas databases are well suited for the storage of data. What do you mean you don't want to download the image? It has to be downloaded to be displayed.

'I dont want to download image' i mean i want the image to be displayed in preview format and not like dowloading to store or something. Hope am making myself clear. Still that brings us back. How do i get it done (saving on folder and url in db)

Thanks

Link to comment
Share on other sites

No, it still isn't really clear what you're asking. Are you talking about a thumbnail preview of the image, which you'd then link to the full size image? In either case, the browser can't display the image without downloading it.

Link to comment
Share on other sites

No, it still isn't really clear what you're asking. Are you talking about a thumbnail preview of the image, which you'd then link to the full size image? In either case, the browser can't display the image without downloading it.

 

The image to be uploaded is limited to a passport size photograph. the user fills a form containing his/her data and browse for a passport in the area provided and clicks upload, he sees the passport in the area meant for passport and then clicks submit so that the data gets to the database. the admin on the other hand queries for a user and gets the data of the specific query including a view of the image.

 

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">

  <table width="69%" border="0" cellspacing="1" cellpadding="1">

    <tr>

      <td width="13%">Name:</td>

      <td width="29%"><input name="name" type="text" id="name" /></td>

      <td width="58%" rowspan="5" valign="top"><table width="38%" height="118" border="1" cellpadding="0" cellspacing="0">

        <tr>

          <td align="center">Passport</td>

        </tr>

      </table></td>

    </tr>

    <tr>

      <td>Sex:</td>

      <td><select name="select">

        <option selected="selected">Sex</option>

        <option>Male</option>

        <option>Female</option>

      </select>      </td>

    </tr>

    <tr>

      <td>Email:</td>

      <td><input name="emal" type="text" id="emal" /></td>

    </tr>

    <tr>

      <td>Address:</td>

      <td><input name="address" type="text" id="address" /></td>

    </tr>

    <tr>

      <td>Phone:</td>

      <td><input name="phone" type="text" id="phone" /></td>

    </tr>

    <tr>

      <td> </td>

      <td> </td>

      <td><input type="file" name="file" />

      <input name="Upload" type="submit" id="Upload" value="Upload" /></td>

    </tr>

    <tr>

      <td rowspan="2"> </td>

      <td> </td>

      <td> </td>

    </tr>

    <tr>

      <td><input type="submit" name="Submit" value="Submit" />

      <input name="Reset" type="submit" id="Reset" value="Reset" /></td>

      <td> </td>

    </tr>

  </table>

</form>

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.