I get some inputs from database with $.ajax in jQuery and it will appear when user click on button:
HTML
<div id="div1"></div>
<input type="button" id="button1"/>
JQuery
$("#button1").click(function() {
   $.ajax({
      type: 'POST',
      url: "get.php",
      data: {vals: "send"},
      success : function(response) { 
         $("#div1").append(response);
   }});
})
After import elements to div, it will have one input type="file" like this:
EDIT: My Form Code is here:
HTML
<input name="upload1" id="upload1" type="file"/>
<input type="button" value="submit" id="button2"/>
JQuery
$("#button2").click(function() {
    $.ajax({
        type: 'POST',
        url: "uploadPhoto.php",
        data: {filename: filename},
        success : function(response) {      
            alert(response);
        }
    });
})
PHP
$filename = $_POST['filename ']; 
$target_dir = "image/";
$target_file = $target_dir . $filename;
var  $src_temp = $_FILES["upload1"]["tmp_name"];    
if (move_uploaded_file($src_temp, $target_file)) {
echo 'success';
}
END EDIT 1
When I want get $_FILES["upload1"]["tmp_name"] for this button to find temp folder of uploaded file in PHP code, it can't find the input that have upload1 name.
How can find a input name in PHP codes?
 
    