pleek Posted March 30, 2008 Share Posted March 30, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/ Share on other sites More sharing options...
BlueSkyIS Posted March 30, 2008 Share Posted March 30, 2008 "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'>"; Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-505094 Share on other sites More sharing options...
pleek Posted March 30, 2008 Author Share Posted March 30, 2008 but with that i have to know the exact name of the uploaded file. Can i use a variable to have it work with what ever the file uploaded is named? So that the url of the picture will print onscreen. After uploading an image? Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-505104 Share on other sites More sharing options...
BlueSkyIS Posted March 30, 2008 Share Posted March 30, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-505108 Share on other sites More sharing options...
pleek Posted March 30, 2008 Author Share Posted March 30, 2008 ok i get what you are saying. But i don't have any clue how to do it. Also will what you described echo all the image's urls or just the one uploaded by the user? Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-505112 Share on other sites More sharing options...
pleek Posted March 31, 2008 Author Share Posted March 31, 2008 Is there any way i can store the name of the file in a variable? because if i can do that i think i can accomplish what im trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-506026 Share on other sites More sharing options...
discomatt Posted March 31, 2008 Share Posted March 31, 2008 My suggestions is to look at the code you're using to upload the actual image. You should find out how to do what you want to do fairly easily if you understand it Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-506036 Share on other sites More sharing options...
pleek Posted April 1, 2008 Author Share Posted April 1, 2008 Well thanks for all the help but i just stumbled on a script that does exactly what i want it to do. So im just going to compare scripts and combine them to make one great one. Thanks for all the Help Guys!!! Quote Link to comment https://forums.phpfreaks.com/topic/98682-php-picture-upload-modifcation-help/#findComment-506054 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.