0

I am troubling to insert doc file into db with other data.

here is my all code: jQuery: new_req.php

passdata = "<passdata><fdata>" +
                "<jobtitle>" + jobtitle + "</jobtitle>" +
                "<action>" + "add_new_req" + "</action>" +
            "</fdata></passdata>";


$.ajax({
            type:"POST",
            url:"model_req.php",
            data:"data=" + encodeURIComponent(passdata),
            success: function(data,textStatus,jqXHR){
            if(data.indexOf("ERROR")>=0){
                 alert(data);
            }
            },
            error: function(jqXHR,textStatus,errorThrown){
            alert("some error occured->" + jqXHR.responseJSON);
            }
            })

HTML:

<form name="inputform" id="inputform" class="form-horizontal col-md-12" method="post"
style="height: 550px; width: 900px" enctype="multipart/form-data">

 <label class="control-label col-sm-2" for="pwd">Attachment</label>
 <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
 <div class="col-sm-3">
   <input name="userfile" type="file" id="userfile" >
 </div>

both html and Jquery code on same page i.e new_req.php

model_req.php file:

$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

Here I got userfile undefined, I tried

if(isset[$_FILES['userfile']['name']])

but still got error.

what to do? How I manage to insert a data with file attachment at same time? Help?

Mangesh Kolape
  • 65
  • 1
  • 10

0 Answers0