0

I have this file input field:

<input type="file" name="file" id="file">

and my ajax code is:

$(function () {
$('#pageContentForm').on('submit', function (e) {
    var file_data = $('#file').prop('files')[0];
    var form_data = $(this);
    form_data.append('file', file_data);
    if (!e.isDefaultPrevented()) {
        $form = $(this);
        var actionURL = $form.attr('action');       
        var currentUrl = location.href;

        $.ajax({
            type: "POST",
            url: actionURL,
            data: form_data.serialize(),
...

and my php file:

if(!is_dir($img_target_dir)){
    mkdir($img_target_dir, 0777, true);
}

$target_file = $img_target_dir . basename($_FILES["file"]["name"]);
if (!file_exists($target_file)) {
    move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
}

but not create the file just the directory...why can be happen this? Thanks for the helps!

kodaek99
  • 135
  • 2
  • 13

0 Answers0