Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: [?]Pictures and PHP

  1. #1

    [?]Pictures and PHP

    If I create a log in using session variables (for example (strings)$usernm, $psswd, and (boolean) $loggedin) is it possible to restrict the viewing of a certain picture only to one username?

    In other words, if user x wants to see a graphic that I uploaded for him, but I only want user x to be able to see it, is there any way to do this (using the session variable described above)?

    Thanks,
    Matt

  2. #2
    yes

  3. #3

  4. #4
    yes, and think of including arrays... that's only a hint ;-)

  5. #5
    I guess I would use arrays or 2d arrays to store the information for each user and to store which pictures each user could view.

    The if statement is useful, but it would still be possible for someone else to type in mywebsite.com/image.jpg and get access to the picture.

    Is there any code or anything I can do to directly hide the picture?

  6. #6
    amitgeorge's Avatar
    646
    posts
    -1 posts per day. Huh ?
    so hide your image in an unknown directory, use a php file to open the image, read its contents and then show it as image. you will need to use content-type headers, . you can also keep the imae in the database

  7. #7
    yep, he's absolutely right!

  8. #8
    Thanks! This sounds really useful. Can someone just answer some of the questions I have either with a post or a link to somewhere where I can find the answers.

    What are content-type headers?

    How can you store an image in a database?

    An when a php file reads the image contents, is it simply just displaying the image?

    Thanks again.

  9. #9
    1. those headers are telling, what to display

    2. yes, you can

    3. this question is answered by 1st on

    4. read the manual (www.php.net)!

  10. #10
    763
    posts
    Registered User
    Just to clarify, you don't actually store images in a database, you only store the names

  11. #11
    You sure can if you want to...

    http://www.evolt.org/article/Storage...rt_1/20/27237/

    You should be able to find more if you google with 'save image mysql database blob' or something...
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

  12. #12
    lunatic's Avatar
    9,895
    posts
    "I feel like I'm taking crazy pills!"
    I spent a day reading posts over on the devshed forums about storing the actually images in the blob field of a sql database and came to the conclusion that while it is possible it is kind of a pain in the butt. The preferred method was to store the images in a directory on your sever and store the paths to the images in the database. They you can just use the img tag say on your webpage. This doesn't really answer the question you originally posted but what the heck.

    Just my $0.02 - will save you some time on research of your own.

    "i walk in stride with people much taller than me and partly it's the boots but mostly it's my chi and i'm becoming transfixed with nature and my part in it which i believe just signifies i'm finally waking up "


  13. #13
    763
    posts
    Registered User
    Interesting, I just read the link Cyan posted. Didn't know you could do that, but to be honest I'm not sure I would want to.

    Nice to know though

  14. #14
    just have the image stored in a some crazy long directory, have PHP fread it, then output what it freads with an image header and no one will ever have the actually directory of the image. you can also have PHP check the login before it starts to fread

  15. #15
    All I said was that it can be done, lunatic and Digitalosophy...

    And both method have their own strong/weak points... If I were to save the image file as Blob into the database, it'd be great since I don't have to worry about 'where' the image is stored and if the image file is somehow corrupted or missing, but that'll make the database file very huge...
    CyanBlue / Jason Je / Flash Developer
    http://CyanBlue.FlashVacuum.com
    http://www.FlashVacuum.com

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012