Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    (www.drattis.com) Since my last thread post i've done this:

    Put up an "upload" page, where users submit a title and an image. After this the title, filename and image data gets stored in the DB together with an image ID that gets increased with 1 for every image that gets uploaded. for example: first image => id = 1, second image that gets uploaded => id = 2, etc, etc etc....

    My ambition right now is to get the images uploaded on the site. Say that i upload an image to the website, then i want php to make a new page with the image on it together with the image title which php gets from the database. The newest image will be displayed first the second newest will be displayed second first etc, etc... And i have thought about linking these together with the help of the image IDs.

    Does anyone want to help me with the code? I have no idea how to get this into code. thank you

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    Give me a link to your images.
    I want to see the path to them, and how you named them.

    Essentially, PHP will set a SESSION when the user first visits the page.
    Each time they pick a PREV or NEXT photo, that SESSION value will
    change. If they leave your site and come back, it will still be on the
    correct photo. If they actually close their browser, the next visit will
    begin at the newest photo.


  4. #3
    Junior Member Drattis's Avatar
    Join Date
    Nov 2012
    Posts
    23
    Member #
    33947
    Liked
    1 times
    I don't understand what you mean with give a link to my images, but ill give all of the links i have to all of the things that i relate to images:

    My website: www.drattis.com

    database? I don't know if i can link to it?
    heres my table structure though:

    id - (int) - A_I
    name (varchar)
    image (blobl)
    title (varchar)

    btw the file name (on database) = the name of the file that gets uploaded -- in other words it stays the same

    Another problem i have is that i want the newest page to have the name index.php, and then when a newer one comes to call that one index.php too, but wait...then i have 2 index.php right? problem: how do i get old index to get a normal file name like funnycat76.php

    Thank you!

  5. #4
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    You're no going to be creating a new page for each image...

    You'll create 1 page, and using the session variables he was talking about, those session variable will tell that page what image to load, what description to load, and based on that session variable, you can create your next and previous links to other images...

    I might suggest you add a couple of colums to your table to make things a little easier

    Approved ( can be a numeric character, default to 0, once you approve it change it to a 1 )

    Timestamp ( just throw a timestamp in when its uploaded ) to help the query know which was the last one loaded... And approved.

    I think he was asking for the URL of the folder that you're gonna upload the images to...

  6. #5
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Btw... If you load your images as blob, I've seen some DB's be really slow with those... I'd just upload the image to a folder, and not worry about loading the whole image into the DB.

  7. #6
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    What I would do is upload the image to a folder and name it based on the auto-incremental ID that is produced by the database (to make sure you don't overwrite any previous images).

    As far as having them each on a separate page, you can do that with your token that is appended to the URL (I see that already happening on what you have so far). You can then GET the token and use that to query the database for the correct image.
    That way you end up with a unique URL for each image but only really need one page of PHP
    Freelance Web Developer

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    My idea ...

    All images in one directory.

    Name them however you want.

    In your MySQL table, for each row (image), you have the id, image title, filename, timestamp

    filename is the filename of the photo (not the BLOB) ... don't use BLOB.

    Timestamp is UNIX timestamp.

    When you query, you sort descending by timestamp so the newest is first.

    PHP SESSION will remember the unique ID number of the row.

    If there is no SESSION, It does the query and displays the first in the result.
    It writes the rowID in the users SESSION.
    If there is a SESSION, it finds the rowID in the array of results.
    It looks at the result array to determine which one is PREV and NEXT.


  9. #8
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    mlseim, if you remember the original thread, Drattis is looking for a way to allow users to upload their own pictures automatically.
    Allowing users to name the pictures whatever they want could result in two images having the same name. PHP upload scripts will overwrite existing images without even giving a warning which is why I suggested that the images have a name based on the auto-incremental ID that is generated by the database.
    By appending the ID to the file name, you can be sure that no two files will have the same name and be overwritten.
    Freelance Web Developer

  10. #9
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,716
    Member #
    5580
    Liked
    718 times
    That is correct. The auto-increment number added to a filename would make it unique.
    You could just ignore the filename that was used when uploading and create your own.
    Example: p_34.jpg, p_223.jpg

    That would be a nice way because you know every photo filename starts with "p_" and then the row ID number.

    Essentially, you would no longer need the filename in your database table. That would save a step.

    If you wanted, you could automatically create a thumbnail for each one as well ...
    p_t_34.jpg, p_t_223.jpg

    It would also be nice to only allow one filetype (JPG). That would keep things more universal.


  11. #10
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    I always just generate a timestamp ( year_mon_day_hour_minute ) and append to anything that could potentially be named the same... Been using that for years and never fails... Also gives me an easy way to identify old files.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 02:29 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com