-
-
Save devluis/9845996 to your computer and use it in GitHub Desktop.
Revisions
-
SoldierCorp created this gist
Mar 28, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ <!doctype html> <html lang="es"> <head> <meta charset="UTF-8"> <title>Eliminar archivo con PHP y jQuery Ajax</title> <!-- Bootstrap--> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <!-- jQuery--> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script> $(document).on('ready', function() { $('a').on('click', function(e) { e.preventDefault(); $.ajax({ url: 'process.php', type: 'post', dataType: 'json' }) .done(function() { alert("Eliminado correctamente!"); }) .fail(function() { alert("Ha ocurrido un error"); }) .always(function() { }); }) }) </script> <style> body { width: 30%; margin: 30px auto; } </style> </head> <body> <h1>Eliminar archivo con PHP y jQuery Ajax</h1> <a herf="#" class="btn btn-primary">Eliminar archivo</a> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <?php $file = 'imagen.png'; $json; if (is_file($file)) { chmod($file,0777); if(!unlink($file)) { echo false; } echo $json['success'] = true; } else { echo false; } ?>