How can you upload an image to MYSQL using php?

Ok this is a joint thread with one of my other ones because no one else  was posting on it, so I did not get what I needed, so, How can you  upload an image to mysql so when some one logs on to my site, they see  or can upload there own avatar, now there are loads of problems with  this, 1) many people don't know how, 2) It's not every day you try to  encode a image into mysql, 3) Letting people upload images into mysql  can cause traffic problem with people trying to log in. So that's it.

Uploading images into MySQL is a bad idea, for more reasons than you mention. You should store the images in a directory on the server instead. But if you want to learn the hard way, here is the method:
The mysql data type must be blob.
The form enctype must be multipart, like this: enctype="multipart/form-data"
The form input field myst be type file, like this: <input type="file" name="upload"/>
Here is example code that prepares the variable $photodata to be inserted into the database.
  $uploadfile = $_FILES['upload']['tmp_name'];
  $photoname = $_FILES['upload']['name'];
  $uploadtype = $_FILES['upload']['type'];
  if ($uploadfile != "") {
$tempfile = fopen($uploadfile, 'rb');
$filesize=filesize($uploadfile);
$width=getimagesize($uploadfile);
$widthx=$width[0];
$heightx=$width[1];
if (($widthx > 102) or (heightx > 135)){
$image_too_big = " but the image size was too large and was not submitted.";
} else {
$photodata = fread($tempfile, filesize($uploadfile));
$photodata = addslashes($photodata);

Similar Messages

  • How can i upload a image file to server by using jsp or servlet.

    Hi,
    I m gurumoorthy. how can i upload a image file to server by using jsp or servlet without using third party API. pls anyone send me atleast outline of the source code.
    Pls send me anyone.
    Regards,
    Gurumoorthy.

    I'm not an applet programmer so I can't give you much advice there.
    If you want to stream the file from the server before it's entirely uploaded, then I don't believe you can treat it like a normal file. If you're just wanting to throw it up there and then listen to it, then you can treat it like a normal file.
    But again, I'm not entirely certain. You might be able to stream the start of the file from the server while you're still uploading the end of it, but it probably depends on what method you're using to do the transfer.

  • We are evaluating the use of iPod touch devices to record best practice videos on our manufacturing floor and to post to an internal Moodle web site. How can you upload a video from the iPod touch to a site other than YouTube?

    We are evaluating the use of iPod touch devices to record best practice videos on our manufacturing floor and to post to an internal Moodle web site. How can you upload a video from the iPod touch to a site other than YouTube? The Moodle upload interface is expecting a file selection dialog box like windows or OSX. I do not want to have to go through an intermediary step of messing with a pc.
    Thanks!

    It should be around 7 and a half gigs. In iTunes, across the bottom there should be a bar that show how much storage is being used and by what. (music, movies, apps, etc.) To make music take up less room, you can check the box to make it convert the music to 128kbps AAC. This lowers the quality, but with most earbuds and speakers, you can't even tell the difference.
    The iPod touch has parental controls built in. You'll find them in Settings. I think they only work for enabling/disabling Safari, Mail, YouTube, and App Store. Here's an app that does more: http://www.mobicip.com/online_safety/ipod_touch

  • How can you upload a movie to I tunes then sync with Ipad2?

    how can you upload a movie to I tunes then sync with Ipad2?

    There are several options to choose from its either you will buy directly from itunes which go directly to movie. Another option is that convert first your movie to mpeg4 by using any converter software, then after converted drga the file (movie) to itunes library. Next thing you will do is to click your account (your ipad device) then look movie tabs then check sync movies.

  • How can you add an image in Mail without being an attachment?

    How can you add an image in Mail without being an attachment?
    In otherwords I'd like to put my logo in the email not as an attachment but as an image.
    Is there a simpel solution to this problem?

    PBN1 wrote:
    How can you add an image in Mail without being an attachment?
    You don't.
    It's not possible. The e-mail protocol is designed for text; anything else has to go as an attachment.
    Different mail clients (such as Mail.app, the mail client bundled with Mac OS X) may have different ways of handling such attachments, but they are still attachments. Each mail client has its own rules and methods, so one may display a picture as if it were in the body of the message, but another client may do something completely different.
    A way of faking it is to format your message in HTML (which is a kind of text). The image is hosted on a remote server, not added to the message; instead, you include a link to it in the body of the message, as you would when building a web page. (This is also what the two tips helpfully provided by X423424X do, except that the link to the image is added in the signature, rather than the body of the message.) What exactly happens to it is, again, at the discretion of the mail client. In my case, for instance, displaying images in HTML messages is turned off, and will stay resolutely off.

  • How can I upload an image to this forum

    How can I upload an image to illustrate a problem? I have a tiff image of 41K, and I click on the camera icon to try to upload it, but an error message says
    "[The content type of this image is not allowed.]". What do I have to do?
    Thanks

    You need to use a jpeg image or a PNG image. Use GraphicConverter 7.3 to change the format.

  • How can you upload photos to FaceBook from iPhoto without using the sync where is deleted in iPhoto it will be deleted in FaceBook

    How can you upload photos from iPhoto to FaceBook without having the sync where if you delete from iPhoto you delete

    I think you have to have the files on your HD. So either put them in iPhoto or copy them to a folder in Finder, and from there you can upload to Facebook.

  • How can you upload a PDF to  a web site

    How can you upload a PDF from iBook to a website? Is there an app that can upload files to the Internet

    Not possible from within Reader for iOS.

  • How can I upload a (image) file through an applet ?

    How can I upload a (image) file through an applet ?

    have a look at http://www.haller-systemservice.net/jupload/
    i'm using Apache Jakarta HTTPClient to create a new HTTP connection to the webserver and sending a new POST request, which holds the image file. (So it's RFC1867 conform)
    there is also an open source implementation of such an applet on sourceforge. it's also called JUpload, but i think it's not maintained any more.

  • How Can You Track Your Ipod If Lost Using The Serial Number

    How Can You Track Your Ipod If Lost Using The Serial Number?

    The find my iphone app has nothong to do with it.
    That app simply allow you to find other devices using your ipod.  It has nothing to do with fining the device on which it is installed.
    If you set up the find my ipod feature that is built into your ipod and the ipod is on and it is connected to wi-fi and it has not been restored, then you may be able to get an approximate street address using icloud.
    Othrewise, it cannot be tracked.

  • How can you purchase additional cloud storage without using account credit?

    How can you purchase additional cloud storage without using account credit? Want credit to remain on accounts as it was a gift for my daughter and we haven't finished using it yet but need to purchase additional storage for all of our accounts. Can't I just override the automatic payment from the account and just pay with a separate cc?

    Purchasing additional storage will not use account credit anyway.  It gets directly charged to your credit card, and you must use a credit card since it is an annual subscription service you are purchasing, not a one time payment option.  They insist on a credit card so they have a billable account for the automatic annual subscription fee.  At least it was that way when I did it.
    Sorry - http://support.apple.com/kb/HT4874  either I did not have enough credit at the time or something has changed since I did it?  Maybe call Apple and do it over the phone (explain why you want to do it that way)?

  • How can you make an image adjustment on all images in a Stack

    If one had a stack of images that need a brightness adjustment. How can you preform the adjustment a stack of images that need the same amount of adjustment?
    Many times I have a stack of images that need a +10 brightness adjustment on them and it would save a lot of time if I could do it on a whole stack of images.

    good points, as l/s takes every adjustment ... including autolevels/exposure ... BUT DOESN'T make them auto to the next image(s), it just lifts the current image settings !!! which is fine for a five shoot series all at the same exposure, but not so much when it is not !!!

  • How can I upload/display image within a record ?

    Hi,
    I like to integrate an image into a record. Say, we have a table with columns: name, address, telefon, image
    How do I upload the image into that very "image" field and display it in a report ?
    <br>TIA
    <br>Bernhard

    Greetings,
    I have a question. Following the howto on the upload/download app, and then being able to successfully upload the image into the DB, is it possible to reference this image from with the Portal tablespace. IE, can I do an <img src="whatever here"> call and be able to pull that image into a portal page. Can I reference it outside HTMLDB?
    -- Thanks in Advance
    -- Cliff Moon
    -- UTPA Webmaster

  • Can you upload a photo to eBay using iPad 2.

    Can you upload a photo taken on iPad 2 to eBay if yes how .

    There is an eBay for iPad app which should let you upload photos to it.

  • How can you make an image change every time you refresh a page?

    Hi.
    I've recently redone my website and was wondering how I could make the image on my main page change every time you refresh the page?
    Like is there a certain script you can use?
    Here's my website
    www.liamfawcett.com
    Thanks

    Copy & Paste the following JavaScript code between the <head> and </head> tags in your HTML document, in Code View of course.
    <script type="text/javascript">
    <!--//Random Banner image on Page Reload
    //store the images in arrays below
    images = new Array(5);
    images[0] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[1] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[2] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[3] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    images[4] = "<a href='http://www.example.com'><img src='some_image.gif' </a>";
    index = Math.floor(Math.random() * images.length);
    document.write(images[index]);
    //done
    // -->
    </script>
    In the array, change URLs (http://www.example.com) to your own links.  Change images (some_image.gif) to your own images.
    Save page.  Preview in browser.  Hit refresh (F5 or Ctrl+R) to see the images change.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

Maybe you are looking for

  • Macbook pro early 2011 - overheat and crash with blue screen and glitches

    Hi since last wednesday my MBP has started to freeze and then crash with bluescreen, glitches and so on... Most of the time doesnt not restart with any command as is overheating as well. I did a clean installation on friday night and i am now running

  • Addition of Pricing conditions for P.O

    Hi How to Add additional condition type to a customized pricing procedure. Can just go though new entries or copy the existing any condition type and rename it. Regards RG

  • Photoshop CS6 computer freeze

    I'm having a continual issue with Photoshop CS6 (13.0.6 x64) completely freezing my MacBook Pro when doing the following action: Edit > Transform > Scale I am able to use this action instead without any issues: Edit > Free Transform About my Mac: OS

  • Casting objects with reflection possible?

    I have this code: String className = "com.xyz.MeasurementUnit"; Class provider = Class.forName(className + "Provider"); Object object = context.getContractProxy(provider);The last line returns an object of type object. I must execute the method getIs

  • Identifier 'ORA_ASPNET_PROF_GETPROPERTIES' must be declared

    Hello, I'm using the OracleProfileProvider - my web.config looks like: <profile enabled="true" defaultProvider="OraProvider"> <providers> <add name="OraProvider" type="Oracle.Web.Profile.OracleProfileProvider, Oracle.Web, Version=2.111.5.10, Culture=