1

first time posting and its because it have no more ideas why this is, i have the following code

HTML

<div> <p> <font face='Verdana, Tahoma, Arial' size='3'> <b> Subir Archivo </b></font> </p>
<!--Formulario para elejir el archivo a subir -->
<form action='' method='post' name='form_ftp' id='form_ftp' enctype='multipart/form-data'>
<font size='2' face='Verdana, Tahoma, Arial'> Elegir archivo :<br>
<div> <input name='archivo' onchange='myApp.fileCheck(this)' class='btn btn-info btn-xs' id='files' type='file' style='padding:2px; font-size:12px; width: 275px' /> </div><br><br>
<input type='hidden' name='opt' value='$id'>
<input name='submit' type='hidden' value='1'>
<input type='hidden' id='path' name='path'>
<input id='subir' onclick='myApp.uploadIt()' type='button' class='btn btn-info btn-xs' value='Subir Archivo' style='display:none;padding:2px; font-size:12px; width: 90px;' /> </font> </form> </div>

JS

uploadIt:function(){

        $('#cargando').show();
        $('#path').val(myApp.rPath);
        var formData = new FormData($('#form_ftp')[0]);
        $.ajax( {            
            url: './controllers/ftp/ftpController.php',
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false
        }).done(function(){
//            $("#files").val('');
//            myApp.getData();
        });

    },

Ok this is good its working pics of that now Params File Passing at last

Params

Now checking the php Code its empty nothing it's passed

PHP codes i used to check its a var dump

var_dump($_POST,$_GET,$_FILES,$_REQUEST);

to see the var dumps params

varDump

varDump

the response its giving me its the else, that's mean there is nothing that to do, no post or get of any kind but the params are passed. why this is happening

Rusty
  • 7,112
  • 10
  • 46
  • 69

2 Answers2

0

You need read the request body: file_get_contents( 'php://input', 'r' );

C Würtz
  • 708
  • 7
  • 20
  • if i use that method how i can get the file data, its give me string only i checked php manuals and there arent a wise advise. also i have some more params on the form that are in bottom if u see the html code are input type hidden. – Gabriel Verges Jun 15 '16 at 13:55
  • See http://stackoverflow.com/questions/21044798/how-to-use-formdata-for-ajax-file-upload – C Würtz Jun 15 '16 at 14:09
0

Updated.

  var formData = new FormData(document.getElementById("form_ftp"));
  $.ajax({
    url: './controllers/ftp/ftpController.php',
    type: 'POST',
    data: formData,
    cache: false,
    processData: false, 
    contentType: false,
    error:function(jqXHR, textStatus, error){
        //Do something on error
        console.log(error);
    },
    success:function(data){
        //Do something on success
        console.log(data); //Response data
    }
  });
ksealey
  • 1,446
  • 1
  • 14
  • 14
  • if i serialize the form the file wont go trough the post, thats why i do the form data like i did it, i faced that problem before – Gabriel Verges Jun 15 '16 at 13:45
  • Still Empty. nothing. this is kidding me, its give me the response of success data, the else statement of the php code – Gabriel Verges Jun 15 '16 at 14:04
  • at the top of your php script write `var_dump($_POST); exit;`. are the values passed shown in your console? – ksealey Jun 15 '16 at 14:07
  • i did that i can show u the whle php document ant they are empty. post . request. get and file are empty. C:\wamp\www\gestionTal\controllers\ftp\ftpController.php:32: array (size=0) empty C:\wamp\www\gestionTal\controllers\ftp\ftpController.php:32: array (size=0) empty C:\wamp\www\gestionTal\controllers\ftp\ftpController.php:32: array (size=0) empty C:\wamp\www\gestionTal\controllers\ftp\ftpController.php:32: array (size=0) empty the response for var_dump – Gabriel Verges Jun 15 '16 at 14:12
  • line 32 its before some checking if the user can do the actions and controllin the session also including files so its the first affter all the controls before user can do anything – Gabriel Verges Jun 15 '16 at 14:14