Your IP: 54.224.162.138 

Asynchronous image file upload without AJAX

( Please Upload JPG file. ) - Download Source Code
 

View Comment
Post Date: Jul 03, 2009 05:54:25
chaitali debnath says:
Comment:
Here after uploading an image if anyone want to remove the uploded image that part is not working.can anybody help me how to remove image after uploading with ajax
Post Date: Jul 06, 2009 12:37:45
Asif D. Khalyani says:
Comment:
Hi, chaitali debnath 

You can remove function image path to call ajax function delete those image, very easy.
Post Date: Aug 26, 2009 10:39:58
virk6 says:
Comment:

Hello,
Please, can you give us the source code of the ajax function to delete an image and also a function to refresh the frame after the delete completes ..

Thanks you very very much ..
Post Date: Oct 12, 2009 12:21:25
Asif D. Khalyani says:
Comment:
On Oclick you can call delete function call & remove that image easily
Post Date: Oct 18, 2009 09:41:53
virk6 says:
Comment:
Mr Asif D. Khalyani, have you tried this delete function to remove image easily  ??
It is not working at all and you get this error message : x Y: usrname..
If you have the code source that works well please let me know.

Thanks.
Post Date: Oct 23, 2009 04:58:06
pusp says:
Comment:
please append delete only in client side after the remove btn 
thanks
Post Date: Oct 30, 2009 10:55:26
virk6 says:
Comment:

Please,  what do you mean by "append delete only in client side after the remove btn" ?
which the source code you call client side after the remove btn ?

To resolve this problem can you give me the piece of the code source ?

Thanks you very much..
Post Date: Jan 01, 2010 05:41:19
Bengt says:
Comment:
Hi Asif D. Khalyani says



I don´t now where or what to change in upload script to get the remove function to work.



Could you please help me with the problem.

I´m not so good in programming.



Regards

Bengt
Post Date: Jan 16, 2010 02:04:28
ilker says:
Comment:
remove function won't work....
Post Date: Jan 16, 2010 06:28:56
pioter says:
Comment:
can you help with delete function?
Post Date: Jan 28, 2010 12:14:01
Asif D. Khalyani says:
Comment:
//Upload.php page line No:33 

This Code Here
---------------------------------------------------------------
var myLink1 = par.createElement('a');
myLink1.href = "#";
myLink1.className = "blacklink";
==============================================
/*myLink1.onclick=function(e){alert('x'+' Y: '+'usrname');} */

//We Can Call Here Delete Function Above Line Delete or Comment like this
//I am writing for delete function call here

myLink1.onclick=function(e){delete_image('id');} 
// I am calling function with image id passed


==============================================
myLink1.appendChild(par.createTextNode('Remove')); 
imgdiv.appendChild(myLink1); 

/**** DELETE Image Function delete_image.js this one add in your main index page***/
function delete_image(image_id)
{
       var data;
    data="image_id="+image_id;
    var url = '../script/delete.php'; // Call Delete Page & In this page delete those image & db entry 
    var myAjax = new Ajax.Request(url,{method:'post', parameters: data, onComplete: delete_image_Changed} );
    return false;
}

function delete_image_Changed(originalRequest) 
{
    if (originalRequest.readyState==4)
    {
        //alert(originalRequest.responseText); 
       if(originalRequest.status==200)
       {
               response = originalRequest.responseXML.documentElement;

            var str; var divid; var d_id; var result_flag;
            try {
                result_flag =    response.getElementsByTagName('result_flag')[0].getElementsByTagName('result')[0].firstChild.nodeValue;
                if(result_flag == "true")
                {
                    alert('Image Not Delete');
                }
                else
                {
                    alert('Image Deleted');
                }
                    
            }catch (e) {    
             
            }
       } 
       else 
       {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
       }
    }
}


//** DELETE Image PHP Page  ../script/delete.php ***/
<?php
ob_start
();
session_start();
header('Content-Type: text/xml');
echo 
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
include(
"Database.php"); // Call DB Connection File Include

$image_id $_POST["image_id"];

$qry_delete "DELETE FROM TABLE_NAME WHERE IMAGE_ID = ".$image_id;
myslq_query($qry_delete);

echo 
"<PHPASKS>";
echo    
"<result_flag><result>false</result>";
echo    
"<session>true</session></result_flag>";
echo     
"<result_set>";
echo         
"<divid>10</divid>";
echo     
"</result_set>";
echo 
"</PHPASKS>";

?>


/*** DELETE IMAGE DONE ***/
Post Date: Apr 21, 2010 09:25:10
danilovix says:
Comment:
hello Asif
thanks for your tips but must be there something more easy (and without a DB connection), like:

myLink1.onclick= function() {delete(this.name)};

and a short function to remove the nodes:

function delete(obj) {
      de = document.getElementById('iframe');
      de.removeChild(document.getElementById(obj));
      }

I hate to work with nodes and don't found yet the way to make it work hehe.. 
Post Date: Apr 24, 2010 10:32:32
asdasdasd says:
Comment:
hello! nice script! Just a question: I'm trying to don't store the original jpg, but a resized one (i mean, I could need to have by default all images smaller than 300X300 pixels).

So.. resize.php will create the preview thumbnail. Where I should add a resizing script BEFORE the storing of the original jpg?

thanks a lot.
Post Date: Apr 24, 2010 06:56:40
asdasdasd says:
Comment:
hmmm maybe I got it :D

I've changed "if" part in resize.php:
===================================================
if($_GET['pic']){
    $img = new img('upload/'.$_GET['pic']);
    $width    =    $_GET["width"];
    $height    =    $_GET["height"];
    $img->resize(300,300,true);
    $img->store('upload/'.$_GET['pic']);
    $img->resize(100,100,true);
    $img->show();
}
// and the funct. resize parameters:
function resize($width, $height, $aspectradio){

So, with the first resize I got a medium-sized image, then I store it.
After that, I resize again to get the thumbnail.

I've also changed the first part of upload.php.
=================================================
<?php
    
/*timestamp to get unique names*/
    
$timestampfile time();
    
    
sleep(2);
    
$ftmp $_FILES['image']['tmp_name'];
    
$oname $timestampfile.$_FILES['image']['name'];
    
    
$extenssion strstr($oname".");
    
$fname 'upload/'.$timestampfile.$_FILES['image']['name'];
        if(
move_uploaded_file($ftmp$fname)){
==================================================

to avoid overwritings.

Hope it helps :)
Post Date: Jul 22, 2010 03:05:30
myrtle says:
Comment:
Hi , is there any reason why i am getting this error:



useless setTimeout call (missing quotes around argument?) 

and invalid XML markup, after i download code and run on localhost?

Post Date: Aug 03, 2010 02:48:26
NONAME says:
Comment:
ghfghfyfghfghfg  fghfgh 

fghfghffghg rftyheryyhr

trtyr
Post Date: Aug 29, 2010 10:17:45
toto says:
Comment:
yes i got it
Post Date: Nov 03, 2010 09:00:40
hups says:
Comment:
the upload is wrong what must i do i have no upload and preview
Post Date: Nov 13, 2010 07:56:02
Abdulrasheed says:
Comment:
Please...the image uploads to the server successfully but would not appear in the image placeholder.

I hope you can help me solve this.

Thanks for making a difference...
Post Date: Nov 14, 2010 10:18:42
catali says:
Comment:
to make preview appear in the image placeholder, in upload.php



<?=(int)$_POST['imgnum']?>

<?=$oname?>



change to



<?php echo (int) $_POST['imgnum'?>

<?php echo $oname ?>
Post Date: Jan 21, 2011 11:08:25
Jean says:
Comment:
Please,


How to show a new image on the place of old image?
(And not next to the old image)

Thank you
Post Date: Mar 25, 2011 03:39:10
vikas says:
Comment:
Please, help me

image is uploding and everything is working properly.

<img name="preview_picture_tag" id="preview_picture_tag" src="http://localhost/upload/4.png"></div><div style="width: 180px; height: auto;">


if i click submit button email validation fired.
that time image preview not show.
Post Date: Mar 25, 2011 03:41:12
vikas says:
Comment:
Please, help me

image is uploding and everything is working properly.

<img name="preview_picture_tag" id="preview_picture_tag" src="http://localhost/upload/4.png"></div><div style="width: 180px; height: auto;">


if i click submit button email validation fired.
that time image preview not show.

plz see here
http://www.buysomebody.com/buy.php
Post Date: Mar 29, 2011 05:22:49
vikas says:
Comment:
Please, help me

image is uploding and everything is working properly.

<img name="preview_picture_tag" id="preview_picture_tag" src="http://localhost/upload/4.png"></div><div style="width: 180px; height: auto;">


if i click submit button email validation fired.
that time image preview not show.

plz see here
http://www.buysomebody.com/buy.php


Post Date: Apr 26, 2011 08:14:55
SAN says:
Comment:
Same issue Please help





"How to show a new image on the place of old image?

(And not next to the old image)"



Thank you 
Post Date: Jul 06, 2011 06:54:15
samerhdid says:
Comment:
I Love This Script .
Post Date: Aug 04, 2011 09:12:15
jstudds says:
Comment:
doesn't work for me, upload in the directory works fine but image will not display despite changing 
<?=(int)$_POST['imgnum']?> 
<?=$oname?> 
as suggested
no good
Post Date: Nov 04, 2011 08:28:44
bhaskar says:
Comment:
i need delete image class but not in xml can anyone help me to give function ............pls
Post Date: Feb 22, 2012 04:34:21
sneha says:
Comment:
I am Getting error undefined index image in upload.php please any one can solve this error...
Post Date: Aug 23, 2012 03:05:40
hentaix2 says:
Comment:
Thanks you
Post Date: Oct 11, 2012 01:24:52
kamal says:
Comment:
Removal of image is not working... how to resolve it?
Post Date: Jul 04, 2014 06:40:31
sankarguru says:
Comment:
i got an error undefined index image on upload.php can any one help me..?

Preview Comment
Post Comment