SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question listing images from folder

    hey folks,
    i m in lot of problem. i have a project i m working on. i have a form made which upload file into a folder calls uploads. now i wanna get them to display but before that i wanna send them to database of images but i am confused how.
    All those who wander aren't lost.

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    <?php
     
    $path = "./";
    $dir_handle = @opendir($path) or die("Unable to open folder");
     
    while (false !== ($file = readdir($dir_handle))) {
     
    if(ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $file)){
    echo "<img src='$file' alt='$file'><br />";
    }
     
     
    }
    closedir($dir_handle);
     
     
     
     
    ?>

    try this code

  3. #3
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    just curiosity. suppose if i m making a form which submit text field n upload an image in a database. how does the process follow. is it the image upload inupload dir and create a id for itself in blob field in mysql and like this or wht is the system/process involved in this?
    All those who wander aren't lost.

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should not store images in database, just the path to the images.
    my mobile portal
    ghiris.ro

  5. #5
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    how do i store its path? with a relational database like a form with a option for pic upload.
    All those who wander aren't lost.

  6. #6
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this:
    PHP Code:
    <?php
    if (isset($_POST['submit']))
    {
        
    $img "images/" $_FILES['myFile']['name'];

        if (
    move_uploaded_file($_FILES['myFile']['tmp_name'], $img))
        {
            
    mysql_query("INSERT INTO images SET path='$img'") or die(mysql_error());
        }
    }
    ?>
    <form action="" method="post" enctype="multipart/form-data">
     <input name="myFile" type="file" /><br />
     <input type="submit" name="submit" />
    </form>
    my mobile portal
    ghiris.ro

  7. #7
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    so this is all to sending a image into images folder n sending a path to mysql on where it is stored? or there is something else?
    what i m looking for is when i upload an image in php directory images using a form filled from my cms. the image goes into images folder and mysql give that image an id to identify which is at image 1 or 2 and so on
    All those who wander aren't lost.

  8. #8
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes
    my mobile portal
    ghiris.ro

  9. #9
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well i will try and keep u posted. thnx for now
    All those who wander aren't lost.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •