Okay well i have a new upload site i been working on for a few days. Has my login/register system and my upload system. When you register it makes you, your own folder chmod to 755 and the folder has the name you registered with on it. So when you upload it uploads to your folder.
So here is an example.
Index of /whitey
That shows your uploads in your folder.
Well i am going to make a PHP script in the folder that shows all the users images.. (limits 20 per page) but the thing is how to make it show all the images in the folder.. Decending by date..
If you could help me start this that would be great..
How to start this?
Started by Whitey, Jun 09 2008 08:34 PM
12 replies to this topic
#1
Posted 09 June 2008 - 08:34 PM
|
|
|
#2
Posted 10 June 2008 - 03:45 AM
I do not believe the file has an attribute of when it was created - it does have an attribute of when the file was last accessed and last written to (PHP: fileatime - Manual and PHP: filemtime - Manual ). The first thing that jumps out at me is to use a database. Store the file name, date it was created, and any other pertinent information regarding the image in the database. With SQL you can use ORDER BY on the date created column and you are pretty much done - you can even add a LIMIT 20 to only show 20 images. The other possibility is to store a timestamp as part of the images name: untitled-1213098600.jpg. Then just sort by the timestamp.
#3
Posted 10 June 2008 - 04:42 PM
someone gave me this code
But it doesn't really seem to work. And i dont really understand it
P.S The upload has nothing to do with a database ;)
<?php
//Open images directory
$dir = @ dir("/images/icons/");
//List files in images directory
while (($file = $dir->read()) !== false)
{
$imagelist[$i] = array('filename' => $file , 'lastModified ' => filemtime('images/icons/'.$file));
$i++;
}
print_r($imagelist);
$dir->close();
?>
But it doesn't really seem to work. And i dont really understand it
P.S The upload has nothing to do with a database ;)
Edited by Whitey, 10 June 2008 - 05:02 PM.
#4
Posted 10 June 2008 - 06:50 PM
Whitey said:
P.S The upload has nothing to do with a database ;)
#5
Posted 10 June 2008 - 07:33 PM
I figured a way around it with a help of a friend.. i will post what i did later.. atm i need help at something else..
okay so i do
but i want to strip the home.php.. so it shows /upload_script/whitey/ If you guys figure out how to do this before me let me know...
EDIT:
FIgured it out.. To fast for you :)
okay so i do
$_SERVER['PHP_SELF'];gets /upload_script/whitey/home.php
but i want to strip the home.php.. so it shows /upload_script/whitey/ If you guys figure out how to do this before me let me know...
EDIT:
FIgured it out.. To fast for you :)
$address_url = $_SERVER['PHP_SELF'];
$address_url_new = str_replace("home.php", "", $address_url);
die($address_url_new);
Edited by Jaan, 11 June 2008 - 09:13 AM.
Please use tags when you're posting your codes!
#6
Posted 11 June 2008 - 03:43 AM
#7
Posted 12 June 2008 - 09:54 AM
#8
Posted 13 June 2008 - 03:28 AM
Why you do not using database? It's more secure and when you decide add some functions (features) you will see that it was good idea to use database system.
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx
#9
Posted 13 June 2008 - 10:01 PM
Yeah i understand that but this is the way i started it. I will be probably making a version 2 for that some other time.. But i am coding in all different aspects for learning purpose's so if i run into something like this later i will know how to do it. ;)
#10
Posted 14 June 2008 - 05:10 AM
ShowTheUsersImagesMostRecentTwentyImages() - short and self describing name :D
www.jarmalavicius.lt | www.github.com/reekenx | www.twitter.com/reekenx
#11
Posted 14 June 2008 - 06:57 AM
If he were using a database, ShowTheUsersImagesMostRecentTwentyImages() = "SELECT * FROM `images` ORDER BY `date` DESC LIMIT 20"


Sign In
Create Account


Back to top









