Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Creating a User Gallery

  1. #1
    Whitey's Avatar
    Whitey is offline Programming Professional
    Join Date
    Feb 2008
    Location
    Loveland, Colorado
    Posts
    254
    Rep Power
    18

    Creating a User Gallery

    Okay well i am creating a site which will have a user gallery. AKA Each member will be able to upload their photos. (Kinda like myspace).

    Now, a few questions.
    When they upload their image. Should i encrypt the name? and/or Randomize the name?

    When they upload, how can i check to see if that number already exist or not?

    But when i do this, its going to be like the following

    image.php?userID=theiruserid&picID=picID or w/e

    so that it will only find the pic for each userid that was assigned to it.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Creating a User Gallery

    Instead of worrying about filenames (and permissions) why don't you store the images in a database? You can then have a row:

    imageID | userID | image

    The image colum would be a blob and you would store the image there. You could then assign the userID to that column and make the imageID a primary auto-increment field.

  4. #3
    Whitey's Avatar
    Whitey is offline Programming Professional
    Join Date
    Feb 2008
    Location
    Loveland, Colorado
    Posts
    254
    Rep Power
    18

    Re: Creating a User Gallery

    i was gonna store it in the DB.
    Exactly how you did but my main question was. Could that become a problem doing the imageID as a auto-increment or should i make it random number, letters, etc?

  5. #4
    mikelbring is offline Programmer
    Join Date
    Jul 2008
    Location
    Nebraska
    Posts
    118
    Rep Power
    0

    Re: Creating a User Gallery

    I was told that filesystem is better for storing images. I store my images in a filesystem but keep records of them in the database. Like to see your opinion on that.
    Realize the Web Web services and design.

  6. #5
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Creating a User Gallery

    Quote Originally Posted by Whitey View Post
    i was gonna store it in the DB.
    Exactly how you did but my main question was. Could that become a problem doing the imageID as a auto-increment or should i make it random number, letters, etc?
    If you go with the database approach, an auto-incrementing key is the best option. This ensures every entry will be unique, by simply using a random number, you are taking the chance of creating a duplicate key. If you go with the file system approach, I would append a timestamp to each image, this would also ensure that the file name is unique (assuming the user doesnt upload the same file at during same second).

  7. #6
    Feral is offline Programmer
    Join Date
    Jul 2008
    Posts
    163
    Rep Power
    15

    Re: Creating a User Gallery

    You want to be careful when storing the images in the database, if you ever have to move to a different server the size of the database can make in a headache.

    I always use a filesystem+database approach. The images are uploaded to a particular directory and renames such as myimage.jpg_1_15_1231838105 where 1 is the user id, 15 is the images id number from the database, and 1231838105 is the time stamp for when the image was uploaded.

    I then store the information in the database table that contains rows imageId, userId, timeStamp. When an image is requested i use a php file and the request is made like image.php?userid=1&imageid=15, the script pulls the time stamp from the database and sent to the browser.

    This gives the freedom to make attachments or watermarks on the fly.

  8. #7
    Jordan Guest

    Re: Creating a User Gallery

    Quote Originally Posted by mikelbring View Post
    I was told that filesystem is better for storing images. I store my images in a filesystem but keep records of them in the database. Like to see your opinion on that.
    I've never heard this. Any reason why a filesystem would be better?

    Quote Originally Posted by Feral View Post
    You want to be careful when storing the images in the database, if you ever have to move to a different server the size of the database can make in a headache.
    This doesn't really seem logical. If you store the images in the database or on a filesystem you will still have to move the same amout of "space" to move. In fact, storing as files could mean you need to transfer thousands and thousands of files while storing in a database you simply do one dump and import.

  9. #8
    Feral is offline Programmer
    Join Date
    Jul 2008
    Posts
    163
    Rep Power
    15

    Re: Creating a User Gallery

    Yes but when you are dealing with phpmyadmin which on most servers has a import file size of +/- 50,000 KiB which can be exceeded by a couple thousand posts on a popular message board. Adding in the extra blob field for to store the text version of the image you database can get over 1Gig in size pretty fast.

    I had to move a site to a new server a couple weeks ago that stored there images in the database, the attachments table alone was 1.6Gigs. In the case of this site the images where converted to a hex format and inserted into a blob in the database, every time an image was requested the image had to be be recreated from the hex and sent to the browsers. Which also turned out to be why the site ran slowly on the clients old server, causing the reason for the move to a more powerful server.

    I ended up having to write a tool to split the sql file into smaller manageable chunks to be uploaded. If the site was using a file system this would not have been necessary since I only would have had to upload the images and walk away.

  10. #9
    Jordan Guest

    Re: Creating a User Gallery

    Wow, that sounds painful. Using phpMyAdmin could limit you but I assumed any transfer of databases would be done using mysqldump and the mysql console program. I've moved site dbs around 4gb easily using those tools. If you don't have root access, no SSH access and your webhost control panel offers no way of doing this (I know cpanel and plesk both offer the method), I could see how you would dislike the method.

  11. #10
    Feral is offline Programmer
    Join Date
    Jul 2008
    Posts
    163
    Rep Power
    15

    Re: Creating a User Gallery

    Normally I would have uses ssh but the client had gotten burned my another freelancer and was very unwilling to give out information that he didn't feel absolutely necessary.

Closed Thread
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)

Similar Threads

  1. Permissions vs User Creating the database
    By zeroradius in forum Database & Database Programming
    Replies: 4
    Last Post: 09-27-2011, 04:08 PM
  2. Art Gallery - For all members
    By Parabola in forum The Lounge
    Replies: 10
    Last Post: 08-21-2009, 12:01 AM
  3. Help a mac user? Creating an autorun CD on Vista!
    By daraclare in forum General Programming
    Replies: 1
    Last Post: 06-20-2009, 06:07 AM
  4. gallery
    By techker in forum JavaScript and CSS
    Replies: 8
    Last Post: 01-03-2009, 04:19 PM

Tags for this Thread

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