Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload file to a user after it was changed on server
    primarykey
    data
    text
    <p>What I'm trying to do is to change a file with user's input and upload updated file back to user.</p> <p>for now i have some java script that collects data from inputs :</p> <pre><code>$('#collectButton').click(function() { var inputs = $('#someDiv input').get(); </code></pre> <p>Since I collect data I need to send it to my PHP code, it's done by ajax Post and JSON (array transfer).</p> <pre><code>$.ajax({ type: "POST", url: "Some.php", data: {postedData:JSON.stringify(inputs)}, success: function() { alert('done!'); } }); </code></pre> <p>Firebug console confirms data transfer and here comes the problem:</p> <p>In response I see the changed file (simple txt) that SHOULD be uploaded back, but it's not.</p> <p>PHP that I use is:</p> <pre><code>if (isset ($_POST['postedData'])){ $changes = (json_decode( $_POST['postedData'])); .... some changes done by for loop .... header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($nwFile)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($nwFile)); ob_clean(); flush(); readfile($nwFile); // deletes file right after fclose($nwFile); unlink($nwFile); </code></pre> <p>How to do it correct??</p> <p>Why the "header" part of PHP ignored?? </p> <p>PS</p> <p>Stand alone PHP file works grate.</p> <p>problem appears only in "calling PHP"</p>
    singulars
    1. This table or related slice is empty.
    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