folder name and image upload to database

Discussion in 'PHP' started by badmasketa, Oct 4, 2008.

  1. #1
    hi there,

    i want something like :

    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <label>
      <input type="text" name="folder_name" id="folder_name" />
      </label>
      <p>
        <label>
        <input type="file" name="image_name" id="image_name" />
        </label>
      </p>
      <p>
        <label>
        <input type="submit" name="button" id="button" value="Submit" />
        </label>
      </p>
    </form>
    HTML:
    now when the users submit the folder name and image then that folder name and the selected image name should be inserted into database....

    whats the code for this??
    any ideas??
     
    badmasketa, Oct 4, 2008 IP
  2. SeanBlue

    SeanBlue Peon

    Messages:
    110
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I understand you correctly you're trying to allow the user to insert an image file into your database? You want to use the file input type: <input type="file" name="imgfile"> which allows the user to select a file from their hard drive.

    You'll then need to check the file is a .jpg, .gif or .png (or whichever files you accept) before uploading to your database. Check out this page: http://blazonry.com/scripting/upload-size.php which should get you started.
     
    SeanBlue, Oct 4, 2008 IP
  3. badmasketa

    badmasketa Well-Known Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #3
    i want the user inputted folder name and selected image's name to be stored in the table....

    is anybody getting me??
     
    badmasketa, Oct 4, 2008 IP
  4. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it would be like any other insert into a database..
    after image upload, do:

    mysql_query("INSERT INTO images SET folder_name='$_POST[folder_name]', image_name='$_FILES[image_name][name]'");

    or something like that
     
    lui2603, Oct 5, 2008 IP
  5. badmasketa

    badmasketa Well-Known Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #5
    @lui2603:

    Could you please let me know the full script or something like that??

    Thanks
     
    badmasketa, Oct 5, 2008 IP