0

Ok here's the scenario;

I have an upload system which works and uploads image files to a folder called 'upload'.

I also have a homepage.

I want to be able to display the latest file that has been uploaded on the homepage.

How can I achieve this?

Thanks :)

4
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by pritaeas
0

Seems simple enough. If you keep track of the name of the latest file (in a database or a flat file), then you get that name and insert it as an <img statement into the appropriate place on your home page (assuming that it's in PHP or that you can make it a PHP module). You could use a standard file name in the home page if you always copied the latest file to a standard name (over-writing the previous one). The problem with that is if you have different file types (jpg, png etc) then it is no longer standard and it would only work if you converted the format (which of course increases the complexity of the solution).

0

Yes, have a textfile to write the names of the images or name of the image last uploaded by overwriting the name.

<?php 

// set file to write
$file = '..\library/para.txt'; 
// open file 
$fh = fopen($file, 'w') or die('Could not open file!'); 
// write to file 
$nam='imagename';
fwrite($fh, $nam) or die('Could not write to file'); 
// close file 
fclose($fh); 
?>

Then read the file to identify the latest image name

<?php 
// set file to read
$file = '..\library\para.txt' or die('Could not open file!'); 
// open file handle
$fh = fopen($file, 'r') or die('Could not open file!'); 
// read file contents 
$data = fread($fh, filesize($file)) or die('Could not read file!'); 
// close file 
fclose($fh); 
// print file contents 
echo $data; 
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.