Hello Friends,
Few days back I received request from one of the user of blog to add two extra features to our existing multiple image upload script.
1 – How To add limit for upload images.
2 – How To add remove link for each image.
I have added both features in existing image upload script. It is not too complex, we can achieve that in simple steps. Lets start with image upload limit.
First choose limit variable and its limit in upload-file.php file. We can set limit at the time of insertion of images so after checking existing session, find out how many rows database have with current session. It will give number of row and now check it with limit variable. If it is still in limit then allow script to upload more images otherwise display (echo) message of upload limit exceeded.
upload-file.php
// select total rows this this session and check with limit
$check_limit=mysql_query("select * from match_item_image where item_id='".$_SESSION["session_temp"]."'") or die(mysql_error());
//echo mysql_num_rows($check_limit);
if(mysql_num_rows($check_limit)>=$limit)
{
echo "You can upload max ".$limit." picture(s)";
}
else
{
// code for image upload continues....
}
Second one was to add a delete link with each file. This can also be achieved with some ajax code in existing. On index.php file add delete link in response text and call ajax function on that link. This link having image id with it.
$('<span id='+idd+'></span>').appendTo('#files').html('<img src="images/'+file+'" alt="" width="120" height="120" style="margin:5px;" /><br><a href="javascript:void(0)" onClick="deleteFile('+idd+');">Delete</a>').addClass('success');
Now this deleteFile function will send request to delete-file.php file to delete current image and delete-file.php file will delete image from database and also remove it from folder.
Cheers



November 19th, 2010 at 11:50 am
Hi
Please tell me how can i integrate your codes in wordpress and exactly where. I am just beginner in wordpress and don’t know much about it.
Please help…
November 24th, 2010 at 8:36 am
Hi Gaurav,
Wordpress already provided optimize image upload functionality while posting your post. Just check icons above textarea in add new post page.
December 8th, 2010 at 12:50 pm
Please suggest, this code is not working in IE.
Thanks,
December 8th, 2010 at 1:16 pm
Hi Kulwinder,
Which version you are using? Script is working fine on IE6 & IE7
December 9th, 2010 at 3:30 am
Thanks for your quick response.
Please provide me the link of updated script. I will use that code.
Thanks for your support.
Regards,
December 11th, 2010 at 9:18 am
@kulwinder Script is the same, which mentioned in this post. Please specify the exact problem you are facing along with ie version.
April 21st, 2011 at 11:55 am
I really like your script. It is exactly what I want to do.. How would I add a radio button to all of the photos for the user to choose as default.
The application is in a classified ad and say for example the user uploads 3 images I would like to be a way for the user to choose one as the profile image…
Please advise..
Great script!!!! Just what I have been looking for..
April 21st, 2011 at 7:03 pm
@Dan Thanks. You can do it by just the way I did for delete feature. While receiving response on index page, add radio button besides delete link. Call one ajax function on click event on radio button. This ajax fun will save image id to user table as default image id.
Hope this will help you.
April 23rd, 2011 at 11:42 am
Hi, this is a very nice script. Exactly what I am looking for. Btw I am facing one issue that the images that have uploaded were not visible when I view it in the uploaded folder. Another thing, could you help to add in the resize function for the script as well as I was planning to include a few sizes of images into my site.
Thanks
Fire
April 23rd, 2011 at 2:20 pm
@Fire Thanks. For image upload issue, check your folder permission settings. Make sure it is writable.
Image Resize – Just go through with below post and use resize_picture function when you are uploading your pics.
http://smartcoderszone.com/2010/05/simple-image-resize-script-in-php/
May 11th, 2011 at 1:06 am
thank you very much. i am new to php. admin can you please help me to create a image retrive page using this. to view all images that 1 id has. i tried but is hard. pls help me.
Thank You
May 11th, 2011 at 4:08 am
@Ishan Its pretty simple. Just use basic select query to fetch all records from image table.
Ex. select * from item_image where item_id = 1
Now with the help of loop, you can fetch all images from the result set array.
May 11th, 2011 at 2:47 pm
thankx bro. i ll give a try
i am not sure coz i am new to php. if you can please give a example code then i can understnd. actually i am stuck with this multiple image uploading & retrieving process for each user. 
for about 3 week i am looking for example projects finaly i found yours.now i want to view the pictures. PLS HELP ME!
Thank You
May 15th, 2011 at 1:57 pm
@Ishan Thanks. Give me your email id or drop me an email. I will send you demo example code.
May 16th, 2011 at 11:39 pm
i got your email bro.thank you verymuch.
keep up the good work.
cheerz
June 11th, 2011 at 10:48 pm
Many thanks to you, very useful script!
July 6th, 2011 at 3:20 am
Hi there,
really good stuff however i got problem once delete the thumbnail.
the upload and title field show double or more whenever tried to delete the image. Can you advice what I’m missing or etc?
August 27th, 2011 at 5:08 pm
thanks for this nice sharing
October 16th, 2011 at 11:29 pm
I have a request! Could you develop it so the user can also pick on of the images as a profile pic(default)?
If you have any questions on what I mean, send me an email..
Thanks, Dan
October 19th, 2011 at 8:56 am
Thank you for thenice script. I have tried to integrate to my page but I have problem with the delete funktion. After clik on the detele link will the page duplicated – please see http://www.apartmany-basta.cz/upload/upload1.jpg and http://www.apartmany-basta.cz/upload/upload2.jpg
Can you help me please?
October 20th, 2011 at 4:22 am
@Dan Hope you will get the solution.