Skip to content

Instantly share code, notes, and snippets.

@aavrug
Last active November 8, 2016 08:55
Show Gist options
  • Save aavrug/2d7af40e487920d2081d085853f6814c to your computer and use it in GitHub Desktop.
Save aavrug/2d7af40e487920d2081d085853f6814c to your computer and use it in GitHub Desktop.
Upload File using ist and use that into PHP method
//js code
$('.file-field:file').on('change', function() {
var file_data = this.files[0];
var form_data = new FormData();
form_data.append('file', file_data);
var formUrl = 'upload.php';
$.ajax({
url: formUrl,
dataType: 'text',
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function(response){
console.log(response);
}
});
});
//php code
public function save_file_data()
{
// logic over here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment