0

I have a database of 1000 items with one field being 'images'. This is a text field with the name of a particular image file (PNG or JPG). I'm trying to find a way to include an 'upload' button on my website so that users can upload an image to the server, and it be recorded in the MySQL database.

I've looked at several ideas online and not found anything that either suits my needs or I can get working. All images can be stored in the same folder as they will all have different names.

Does anyone know of any tutorials, or can assist me in doing it, many many thanks x

user2406993
  • 257
  • 3
  • 7
  • 21
  • means u want to save image name in database.if so use $_FILES["file"]["name"] – nickle Jul 05 '13 at 10:03
  • Which are the ideas you've looked at? Why don't they suit your needs, or what problems have you encountered in trying to get them working? – eggyal Jul 05 '13 at 10:05
  • sorry can't be much help there, I just worked through several suggestions I found on google, and either they weren't clear enough (I'm a beginner) or they didn't work for some reason :-( – user2406993 Jul 05 '13 at 10:06
  • you can try [this](http://stackoverflow.com/questions/14560179/upload-an-image-with-jquery-ajax-with-a-duplicate-able-input/14658793#14658793) – am05mhz Jul 05 '13 at 10:08

2 Answers2

0

this is php script to upload image:-

  if ($_FILES['inputfieldname']['name']) {
            $filename = stripslashes($file[inputfieldname]['name']);
            $extension = "get the extension of file";// jpg if image format is jpg
            $extension = strtolower($extension);
            //set target image name
            $image_name1 = date("Ymdhis") . time() . rand() . '.' . $extension;
            $target = "target directory path";
            if ($this->checkExtensions($extension)) {
                $filestatus = move_uploaded_file($file[inputfieldname]['tmp_name'], $target);
                @chmod($target, 0777);
                if ($filestatus) {
                    // insert $image_name into database
                }
            }
        }
Rajeev Ranjan
  • 4,152
  • 3
  • 28
  • 41
0

Read this tutorial ...and also check did u give enctype="multipart/form-data" in form...

Josh Davis
  • 28,400
  • 5
  • 52
  • 67
nickle
  • 4,636
  • 1
  • 13
  • 11