Why not create a file when ajax send?

Good night, ajax processing of files to send.
Files sent - confirmation comes from a ajax'
But here is the code of sending:
$('#postnews').click(function(event) {
 var url = '...';
 var data = $('form#news__form').serialize();
 var file_data = $('#newsimg').prop('files');
 var form_data = new FormData();
 form_data.append('file', file_data);
 url: url,
 type: 'POST',
 dataType: 'text',
 data: {data: data, formData: form_data},
 cache:false, // In POST requests disabled by default, but will touch base
 contentType: false, // Type of data encoding we set in the form is disable
 processData: false, // Disable, since the pass file
 .done(function() {
 }, 2500)
 .fail(function() {
 }, 2500)
 }, 2650)


Php processing done fast, because files will load the admin:
if(isset($_FILES)) {

 //Passed array stored in a variable
 $image = $_FILES['image'];

 // Check file size and if it exceeds the specified size
 // end the script and display error
 if ($image['size'] > 200000) {

 // Get the image format
 $imageFormat = explode('.', $image['name']);
 $imageFormat = $imageFormat[1];

 // Generate a new name for the image. You can save the old
 // but this is not recommended
 $imageFullName = '/newsprev/' . hash('crc32',time()) . '.' . $imageFormat;

 // Save the image type to variable
 $imageType = $image['type'];

 // Check the available formats of images, if the image corresponds to
 // copy the image to the images folder
 if ($imageType == 'image/jpeg' || $imageType == 'image/png') {
 if (move_uploaded_file($image['tmp_name'],$imageFullName)) {
 echo 'success';
 } else {
 echo 'error';

But why is the file in the directory "/newsprev/" is not generated, given the right recording and reading - 766
In form, too, could not make a mistake:
<form method="POST" class="s1_news__form" id="news__form" ENCTYPE="multipart/form-data">
 <label for="newstitle">
 <span class="news__title">Headline news</span>
 <input type="text" name="newstitle" id="newstitle">
 <label for="news">
 <span class="news__title">news Content</span>
 <textarea name="news" id="news" cols="30" rows="10"></textarea>
 <label for="newsimg">
 <span class="news__title">Add photo</span>
 <input type="file" name="newsimg" id="newsimg">
 <label for="postnews">
 <input type="submit" name="postnews" id="postnews" placeholder="Publish">
April 3rd 20 at 17:35
2 answers
April 3rd 20 at 17:37
Probably not enough rights to create the file, put the script right 666.
upd: Saw about the rights, needs a log php.
With logs some problem, the file size increases - but new records are not there... - Jedidiah_Bradtke commented on April 3rd 20 at 17:40
@Jedidiah_Bradtke, you have the logic in one line will appear if you open via Notepad - Margot commented on April 3rd 20 at 17:43
April 3rd 20 at 17:39
1) done(function() will be executed whatever the outcome, if the server returned a code of 200. So this is not to say that on PHP it was fine, only that the script worked.

$imageFullName = '/newsprev/' . hash('crc32',time()) . '.' . $imageFormat;
You have that right in the root of my Linux system there is a folder /newsprev? Riley?

3) the Logs look, there you are likely to find warning that folder which you are trying to record is not present.

4) form_data.append('file', file_data);
$image = $_FILES['image'];
Would you say...

Find more questions by tags AJAXPHP