Jump to content

Recommended Posts

What i have

Ok so i have a code that uploads images to a dir on my server. The script works great but i want to modify it. The script shows all the pictures in the "images" dir that have been uploaded. Here is the script working on my server

 

What i want to do

The current code actually shows all the images that have been uploaded. I would like it to just show the link to the one you just uploaded. I know its possible but i have no clue how to do it. Any ideas?

 

Heres the script that shows the photos in the "images" dir:

 

list_images.php

 

<?
$handle = @opendir("images");

if(!empty($handle))
{
while(false !== ($file = readdir($handle)))
{
if(is_file("images/" . $file))
echo '<img src="images/' . $file . '"><br><br>';
}
}

closedir($handle);
?>

 

There are two other php files also, upload.php and upload_form.php

Link to comment
https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/
Share on other sites

"I would like it to just show the link to the one you just uploaded."

 

just echo the URL for the uploaded files, don't echo the contents of the directory. if you upload a file called someimage.jpg, then echo a a link to that image:

 

echo "<IMG SRC='/path/to/images/someimage.jpg'>";

when a file is uploaded, you have to name it, therefore you will always know the name of the file. there is no function to "show what the recent person uploaded via this script."

 

logic:

 

for each uploaded image, store the name of the image, then echo a link for each uploaded image using the stored image names.

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.