Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery function not posting to php
    primarykey
    data
    text
    <p>I am not a big Jquery guy but am using a plugin which is an image uploader. It has a button to remove images with correlates with the following code.</p> <pre><code>function remove_unwanted_file(id,file) { if(confirm("If you are sure that you really want to remove the file "+file+" then click on OK otherwise, Cancel it.")) { var dataString = "file_to_remove=" +file; $.ajax({ type: "POST", url: "remove_unwanted_files.php", data: dataString, cache: false, beforeSend: function() { $("#vpb_remove_button"+id).html('&lt;img src="images/loadings.gif" align="absmiddle" /&gt;'); }, success: function(response) { $('div#fileID'+id).fadeOut('slow'); } }); } return false; } </code></pre> <p>However, none of the code within the PHP file is ever executed. The alert does pop up and asks you if you want to delete the file with the correct file name. The PHP code is what actually deletes the file however the file does not delete from the file system. I have tried putting other code in the PHP file like sending me an email and none of it executes. Can anyone see anything wrong with this JQuery code?</p> <p>THIS IS THE PHP CODE</p> <pre><code>&lt;?php $to = 'dev@kylevan.com'; $subject = 'the subject'; $message = 'file reached'; $headers = 'From: noreply@mobilehomelist.com' . "\r\n" . 'Reply-To: noreply@mobilehomelist.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); include('ASApiClientServer.php'); include('ASApiClient.php'); $uniquekey=$_SESSION['uniquekey']; $postFields = array( 'referralCode'=&gt;$uniquekey, 'image'=&gt;strip_tags($_POST["file_to_remove"]), ), ); $ApiClient = new ASApiClient(); try{ $ApiClient-&gt;requestResponse('removePicture', $postFields); //handle the call } catch(Exception $e){ print_r($ApiClient-&gt;getRawResponse()); } if(isset($_POST["file_to_remove"]) &amp;&amp; !empty($_POST["file_to_remove"])) { $uploaded_files_location = 'uploaded_files/'.strip_tags($_POST["file_to_remove"]); @chmod($uploaded_files_location,0777); @unlink($uploaded_files_location); //Here you can also delete the file from your database if you wish assuming you also saved the file to your database during upload } ?&gt; </code></pre> <p>The email stuff at the beginning is in there just trying to get it to do something. THe path to the file is correct. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload