I try to use that script in my Drupal site https://tutorialzine.com/2013/05/mini-ajax-file-upload-form

I did not use drupal form api. I used my html same with that script.

I created 2 pages with hook_menu.

On first page I use that script to upload files. That script sends files via ajax to 2. page. But I could not save files as managed file.

On second page I save datas as json to logs to see what i get in that file. That is an example json;


How can I save files as managed file on second page?

| improve this question | | | | |

I solved like that

$file_name = $file['name'];
$file_get = file_get_contents($file['tmp_name']);
$new_file = file_save_data($file_get, 'public://images/'.$file_name);
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.