This is my code
$(document).ready(function() {
var base_url = $('#hiddenBaseUrl').val();
var uploadfolder = $('#uploadfolder').val();
$('#file_upload').uploadify({
'uploader' : base_url + 'flash/uploadify/uploadify.swf',
'script' : base_url + 'uploadify/uploadifyUploader/',
'cancelImg' : base_url + 'css/uploadify/cancel.png',
'folder' : uploadfolder,
'fileExt' : '*.jpg;*.gif;*.png',
'fileDesc' : 'Image Files',
'auto' : true,
'sizeLimit' : 204800, //200 kb
'multi' : false,
'onComplete' : function(event, ID, fileObj, response, data) {
// here i'm gonna resize the images and display it in the main page
$.ajax({
url : base_url + 'uploadify/filemanipulation/' + fileObj.type +'/' + fileObj.name,
success : function(response){
var images = $('<li><a target="_blank" href="'+base_url+'uploads/'+fileObj.name+'"><img src="'+base_url + 'uploads/thumbs/' +fileObj.name+'" alt=""/></a><br /><button>Borrar</button></li>');
$(images).hide().insertBefore('#displayFiles').slideDown('slow')
}
})
}
});
//this is the funcion with delete the image .. but the image is deleted from browser not from folder
//how to delete from folder with jQuery if is possible ?
$('button').live('click', function(e) {
e.preventDefault();
if(confirm('Are you sure you want to delete this file?'))
{
$(this).parent('li').remove().fadeOut('slow');
}
});
//.....
//and this is button2 like button
//i want to delete the image with codeigniter but i have an error ...
// fileObj" not defined
$('button2').live('click', function(e) {
e.preventDefault();
if (confirm('Are you sure you want to delete this file?'))
{
alert(fileObj.name);
var link = $(this);
$.ajax({
url : './uploadify/delete_file/' + fileObj.type + '/' + fileObj.name, // <- this fileObj
dataType : 'json',
success : function (data)
{
if (data.status == "success")
{
$(this).parent('li').remove().fadeOut('slow');
}
else
{
alert(data.msg);
}
}
});
}
});
//and this is the function on codeigniter
public function delete_file($extension, $filename)
{
unlink(base_url().'uploads/' . $filename.$extension);
unlink(base_url().'uploads/thumbs/' . $filename.$extension);
return true;
}
});
the question is how to delete the image from folder with jQuery if is possible
if not how to pass the name (fileObj.name) and the extension (fileObj.type) to the function button2 if is possible
if not how to resolve this ..
Thank you