Jump to content

PHP - Display Recently Uploaded Images


Gamerz

Recommended Posts

Hello,

I have an image uploader.

 

I would like to display all IMAGES (No files) recently uploaded, and add them to the home page.

 

Any tips to get started? Maybe a code, or even a snippet?

 

To get started,

1. I know I need a code to detect whether or not the file is an image or file. If file, the code will skip through, and not display the file. If image, the code will get the image url, and add them to the home page displaying the image.

 

2. I know I need a code to space out each images, so it wont just bunch up.

 

3. I need a code to resize the image to small on screen, so my home page wouldnt be messed up.

----

I just don't know how to code it...help please?

Link to comment
Share on other sites

for #2, #3, HTML, not PHP, will solve your problems.

 

Perhaps...though i wouldn't recommend using the image tag's attributes to 'resize' an image...you're loading a file that is larger than necessary. That's bad for you and for the visitor; neither of you want more bandwidth than necessary. Better to resize it permanantly.

 

Well, do you have the code for it?

 

People aren't here to write your website for you. If you're after that, you should use the freelance section and be prepared to get out your wallet. Third_degree has put you on the right track with number 1, though filetype wont quite do what you need. It'll tell you if something is a file, directory, or something else but not if it's an image. It's probably sufficient to check the extension of the filename for image extensions since you'd hope you're checking any uploaded files to ensure they are images. You'll also need the glob function to cycle through the files in the directory.

Link to comment
Share on other sites

Ben speaks the truth.  If your images are massive, yeah, it'd be better to resize them to thumbnail size either manually or automatically, search "php image resize" on google.  As for filetype(), my bad, he's right it's rather useless in this context, I was speaking from memory, and I guess it failed me :-\.  http://www.php.net/glob will probably do you well.

 

If you're lucky, someone will throw some code at you in this thread, but in the future, don't rely on it.  The best help is help that you need to take and apply to your goal.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.