Problem with uploading a image via Ajax Call in php?











up vote
1
down vote

favorite












I want to upload an image via Ajax call but I am not able to upload the image. Kindly check my code what I am doing wrong:



HTML File:



<input class="form-control" type="file" name="photo1" id="photo1" accept="image/*" onchange="loadFile2(event)">


<button type="button" class="btn btn-secondary btn-lg btn-block" onclick="createDocsVerify()">Update Details</button>


Ajax Call:



<script>
function createDocsVerify () {

var data = {
'photo1' : jQuery('#photo1').val(),
};

//Ajax call Start Here
jQuery.ajax({
url : '/myproject/adminseller/sellerdocsverify.php',
method : 'POST',
data : data,
success : function(data){

if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}

if (data == 'passed') {

jQuery('#modal_errors_3').html("");
location.reload();
}
},
error : function (){alert("Something went wrong.");},

});

}
</script>


Php File: sellerdocsverify.php



if (isset($_POST['photo1'])) {
$photo1 = sanitize($_POST['photo1']);
// var_dump Output: string(20) "C:fakepath553.jpg"
}


$errors = array();
$required = array(
'photo1' => 'Please select Photo 1',
);



// check if all required fileds are fill out
foreach ($required as $field => $display) {
if (empty($_POST[$field]) || $_POST[$field] == '') {
$errors = $display.'.';
}
}


$allowed = array('png', 'jpg', 'jpeg', 'gif');
$photoNameArray = array();
$tmpLoc = array();
$uploadPath = array();



**// Here is the problem**
$name1 = $_FILES['photo1']['name']; // Here is the problem
Var_dump($name1); // OUTPUT: NULL
**// Here is the problem**



$nameArray = explode('.',$name1);
$fileName = $nameArray[0];
$fileExt = $nameArray[1];

$mime = $_FILES['photo1']['type'];
$mimeType = $mime[0];
$mimeExt = $mime[1];
$tmpLoc = $_FILES['photo1']['tmp_name'];
$fileSize = $_FILES['photo1']['size'];

$uploadName = md5(microtime().$j).'.'.$fileExt;
$uploadPath = BASEURL.'images/products/'.$uploadName;

if ($mimeType != 'image') {
$errors = 'The file must be an image.';
}



if (!empty($errors)) {
echo display_errors($errors);
}else{
echo 'passed';

// upload file and insert into database
if ($photoCount > 0) {
move_uploaded_file($tmpLoc1, $uploadPath1);
}

$insertSql = "INSERT INTO docTable (`photo1`)
VALUES ('$photo1')";
$db->query($insertSql);

$_SESSION['success_flash'] = '<span style="color:#FFFFFF;text-align:center;">Data Saved Successfully!</span>';


}
?>


Kind check my code and suggest what I am doing wrong, am I doing something wrong in Ajax call or in php, I am getting the value in $photo1.



Any idea or suggestion would be welcome.










share|improve this question






















  • How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
    – miken32
    Nov 7 at 18:43










  • Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
    – miken32
    Nov 7 at 18:44















up vote
1
down vote

favorite












I want to upload an image via Ajax call but I am not able to upload the image. Kindly check my code what I am doing wrong:



HTML File:



<input class="form-control" type="file" name="photo1" id="photo1" accept="image/*" onchange="loadFile2(event)">


<button type="button" class="btn btn-secondary btn-lg btn-block" onclick="createDocsVerify()">Update Details</button>


Ajax Call:



<script>
function createDocsVerify () {

var data = {
'photo1' : jQuery('#photo1').val(),
};

//Ajax call Start Here
jQuery.ajax({
url : '/myproject/adminseller/sellerdocsverify.php',
method : 'POST',
data : data,
success : function(data){

if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}

if (data == 'passed') {

jQuery('#modal_errors_3').html("");
location.reload();
}
},
error : function (){alert("Something went wrong.");},

});

}
</script>


Php File: sellerdocsverify.php



if (isset($_POST['photo1'])) {
$photo1 = sanitize($_POST['photo1']);
// var_dump Output: string(20) "C:fakepath553.jpg"
}


$errors = array();
$required = array(
'photo1' => 'Please select Photo 1',
);



// check if all required fileds are fill out
foreach ($required as $field => $display) {
if (empty($_POST[$field]) || $_POST[$field] == '') {
$errors = $display.'.';
}
}


$allowed = array('png', 'jpg', 'jpeg', 'gif');
$photoNameArray = array();
$tmpLoc = array();
$uploadPath = array();



**// Here is the problem**
$name1 = $_FILES['photo1']['name']; // Here is the problem
Var_dump($name1); // OUTPUT: NULL
**// Here is the problem**



$nameArray = explode('.',$name1);
$fileName = $nameArray[0];
$fileExt = $nameArray[1];

$mime = $_FILES['photo1']['type'];
$mimeType = $mime[0];
$mimeExt = $mime[1];
$tmpLoc = $_FILES['photo1']['tmp_name'];
$fileSize = $_FILES['photo1']['size'];

$uploadName = md5(microtime().$j).'.'.$fileExt;
$uploadPath = BASEURL.'images/products/'.$uploadName;

if ($mimeType != 'image') {
$errors = 'The file must be an image.';
}



if (!empty($errors)) {
echo display_errors($errors);
}else{
echo 'passed';

// upload file and insert into database
if ($photoCount > 0) {
move_uploaded_file($tmpLoc1, $uploadPath1);
}

$insertSql = "INSERT INTO docTable (`photo1`)
VALUES ('$photo1')";
$db->query($insertSql);

$_SESSION['success_flash'] = '<span style="color:#FFFFFF;text-align:center;">Data Saved Successfully!</span>';


}
?>


Kind check my code and suggest what I am doing wrong, am I doing something wrong in Ajax call or in php, I am getting the value in $photo1.



Any idea or suggestion would be welcome.










share|improve this question






















  • How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
    – miken32
    Nov 7 at 18:43










  • Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
    – miken32
    Nov 7 at 18:44













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I want to upload an image via Ajax call but I am not able to upload the image. Kindly check my code what I am doing wrong:



HTML File:



<input class="form-control" type="file" name="photo1" id="photo1" accept="image/*" onchange="loadFile2(event)">


<button type="button" class="btn btn-secondary btn-lg btn-block" onclick="createDocsVerify()">Update Details</button>


Ajax Call:



<script>
function createDocsVerify () {

var data = {
'photo1' : jQuery('#photo1').val(),
};

//Ajax call Start Here
jQuery.ajax({
url : '/myproject/adminseller/sellerdocsverify.php',
method : 'POST',
data : data,
success : function(data){

if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}

if (data == 'passed') {

jQuery('#modal_errors_3').html("");
location.reload();
}
},
error : function (){alert("Something went wrong.");},

});

}
</script>


Php File: sellerdocsverify.php



if (isset($_POST['photo1'])) {
$photo1 = sanitize($_POST['photo1']);
// var_dump Output: string(20) "C:fakepath553.jpg"
}


$errors = array();
$required = array(
'photo1' => 'Please select Photo 1',
);



// check if all required fileds are fill out
foreach ($required as $field => $display) {
if (empty($_POST[$field]) || $_POST[$field] == '') {
$errors = $display.'.';
}
}


$allowed = array('png', 'jpg', 'jpeg', 'gif');
$photoNameArray = array();
$tmpLoc = array();
$uploadPath = array();



**// Here is the problem**
$name1 = $_FILES['photo1']['name']; // Here is the problem
Var_dump($name1); // OUTPUT: NULL
**// Here is the problem**



$nameArray = explode('.',$name1);
$fileName = $nameArray[0];
$fileExt = $nameArray[1];

$mime = $_FILES['photo1']['type'];
$mimeType = $mime[0];
$mimeExt = $mime[1];
$tmpLoc = $_FILES['photo1']['tmp_name'];
$fileSize = $_FILES['photo1']['size'];

$uploadName = md5(microtime().$j).'.'.$fileExt;
$uploadPath = BASEURL.'images/products/'.$uploadName;

if ($mimeType != 'image') {
$errors = 'The file must be an image.';
}



if (!empty($errors)) {
echo display_errors($errors);
}else{
echo 'passed';

// upload file and insert into database
if ($photoCount > 0) {
move_uploaded_file($tmpLoc1, $uploadPath1);
}

$insertSql = "INSERT INTO docTable (`photo1`)
VALUES ('$photo1')";
$db->query($insertSql);

$_SESSION['success_flash'] = '<span style="color:#FFFFFF;text-align:center;">Data Saved Successfully!</span>';


}
?>


Kind check my code and suggest what I am doing wrong, am I doing something wrong in Ajax call or in php, I am getting the value in $photo1.



Any idea or suggestion would be welcome.










share|improve this question













I want to upload an image via Ajax call but I am not able to upload the image. Kindly check my code what I am doing wrong:



HTML File:



<input class="form-control" type="file" name="photo1" id="photo1" accept="image/*" onchange="loadFile2(event)">


<button type="button" class="btn btn-secondary btn-lg btn-block" onclick="createDocsVerify()">Update Details</button>


Ajax Call:



<script>
function createDocsVerify () {

var data = {
'photo1' : jQuery('#photo1').val(),
};

//Ajax call Start Here
jQuery.ajax({
url : '/myproject/adminseller/sellerdocsverify.php',
method : 'POST',
data : data,
success : function(data){

if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}

if (data == 'passed') {

jQuery('#modal_errors_3').html("");
location.reload();
}
},
error : function (){alert("Something went wrong.");},

});

}
</script>


Php File: sellerdocsverify.php



if (isset($_POST['photo1'])) {
$photo1 = sanitize($_POST['photo1']);
// var_dump Output: string(20) "C:fakepath553.jpg"
}


$errors = array();
$required = array(
'photo1' => 'Please select Photo 1',
);



// check if all required fileds are fill out
foreach ($required as $field => $display) {
if (empty($_POST[$field]) || $_POST[$field] == '') {
$errors = $display.'.';
}
}


$allowed = array('png', 'jpg', 'jpeg', 'gif');
$photoNameArray = array();
$tmpLoc = array();
$uploadPath = array();



**// Here is the problem**
$name1 = $_FILES['photo1']['name']; // Here is the problem
Var_dump($name1); // OUTPUT: NULL
**// Here is the problem**



$nameArray = explode('.',$name1);
$fileName = $nameArray[0];
$fileExt = $nameArray[1];

$mime = $_FILES['photo1']['type'];
$mimeType = $mime[0];
$mimeExt = $mime[1];
$tmpLoc = $_FILES['photo1']['tmp_name'];
$fileSize = $_FILES['photo1']['size'];

$uploadName = md5(microtime().$j).'.'.$fileExt;
$uploadPath = BASEURL.'images/products/'.$uploadName;

if ($mimeType != 'image') {
$errors = 'The file must be an image.';
}



if (!empty($errors)) {
echo display_errors($errors);
}else{
echo 'passed';

// upload file and insert into database
if ($photoCount > 0) {
move_uploaded_file($tmpLoc1, $uploadPath1);
}

$insertSql = "INSERT INTO docTable (`photo1`)
VALUES ('$photo1')";
$db->query($insertSql);

$_SESSION['success_flash'] = '<span style="color:#FFFFFF;text-align:center;">Data Saved Successfully!</span>';


}
?>


Kind check my code and suggest what I am doing wrong, am I doing something wrong in Ajax call or in php, I am getting the value in $photo1.



Any idea or suggestion would be welcome.







javascript php jquery ajax






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 17:36









Sarah

1316




1316












  • How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
    – miken32
    Nov 7 at 18:43










  • Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
    – miken32
    Nov 7 at 18:44


















  • How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
    – miken32
    Nov 7 at 18:43










  • Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
    – miken32
    Nov 7 at 18:44
















How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
– miken32
Nov 7 at 18:43




How do you know you're doing something wrong? Use your browser's inspector to check the POST request. Does everything get sent properly?
– miken32
Nov 7 at 18:43












Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
– miken32
Nov 7 at 18:44




Also check this question and the accepted answer: stackoverflow.com/q/44708023/1255289
– miken32
Nov 7 at 18:44












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You need to do some special "things" to upload files via AJAX. You need to create a FormData object and manually add the file data to it, and also set the contentType, processData and cache options of your AJAX call to false. Your javascript should look like this:



<script>
function createDocsVerify() {
var formdata = new FormData();
var file = jQuery('#photo1').prop('files')[0];
formdata.append('photo1', file);

//Ajax call Start Here
jQuery.ajax({
url: '/myproject/adminseller/sellerdocsverify.php',
method: 'POST',
cache: false,
contentType: false,
processData: false,
data: formdata,
success: function(data) {
if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}
if (data == 'passed') {
jQuery('#modal_errors_3').html("");
location.reload();
}
},
error: function() {
alert("Something went wrong.");
},
});
}
</script>


That should upload the photo.






share|improve this answer



















  • 1




    What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
    – Jay Blanchard
    Nov 7 at 18:38










  • This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
    – José A. Zapata
    Nov 7 at 18:42










  • Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
    – Jay Blanchard
    Nov 7 at 18:44










  • Ok, there you go.
    – José A. Zapata
    Nov 7 at 18:48










  • @Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
    – Sarah
    Nov 7 at 18:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194822%2fproblem-with-uploading-a-image-via-ajax-call-in-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You need to do some special "things" to upload files via AJAX. You need to create a FormData object and manually add the file data to it, and also set the contentType, processData and cache options of your AJAX call to false. Your javascript should look like this:



<script>
function createDocsVerify() {
var formdata = new FormData();
var file = jQuery('#photo1').prop('files')[0];
formdata.append('photo1', file);

//Ajax call Start Here
jQuery.ajax({
url: '/myproject/adminseller/sellerdocsverify.php',
method: 'POST',
cache: false,
contentType: false,
processData: false,
data: formdata,
success: function(data) {
if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}
if (data == 'passed') {
jQuery('#modal_errors_3').html("");
location.reload();
}
},
error: function() {
alert("Something went wrong.");
},
});
}
</script>


That should upload the photo.






share|improve this answer



















  • 1




    What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
    – Jay Blanchard
    Nov 7 at 18:38










  • This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
    – José A. Zapata
    Nov 7 at 18:42










  • Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
    – Jay Blanchard
    Nov 7 at 18:44










  • Ok, there you go.
    – José A. Zapata
    Nov 7 at 18:48










  • @Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
    – Sarah
    Nov 7 at 18:52















up vote
0
down vote













You need to do some special "things" to upload files via AJAX. You need to create a FormData object and manually add the file data to it, and also set the contentType, processData and cache options of your AJAX call to false. Your javascript should look like this:



<script>
function createDocsVerify() {
var formdata = new FormData();
var file = jQuery('#photo1').prop('files')[0];
formdata.append('photo1', file);

//Ajax call Start Here
jQuery.ajax({
url: '/myproject/adminseller/sellerdocsverify.php',
method: 'POST',
cache: false,
contentType: false,
processData: false,
data: formdata,
success: function(data) {
if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}
if (data == 'passed') {
jQuery('#modal_errors_3').html("");
location.reload();
}
},
error: function() {
alert("Something went wrong.");
},
});
}
</script>


That should upload the photo.






share|improve this answer



















  • 1




    What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
    – Jay Blanchard
    Nov 7 at 18:38










  • This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
    – José A. Zapata
    Nov 7 at 18:42










  • Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
    – Jay Blanchard
    Nov 7 at 18:44










  • Ok, there you go.
    – José A. Zapata
    Nov 7 at 18:48










  • @Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
    – Sarah
    Nov 7 at 18:52













up vote
0
down vote










up vote
0
down vote









You need to do some special "things" to upload files via AJAX. You need to create a FormData object and manually add the file data to it, and also set the contentType, processData and cache options of your AJAX call to false. Your javascript should look like this:



<script>
function createDocsVerify() {
var formdata = new FormData();
var file = jQuery('#photo1').prop('files')[0];
formdata.append('photo1', file);

//Ajax call Start Here
jQuery.ajax({
url: '/myproject/adminseller/sellerdocsverify.php',
method: 'POST',
cache: false,
contentType: false,
processData: false,
data: formdata,
success: function(data) {
if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}
if (data == 'passed') {
jQuery('#modal_errors_3').html("");
location.reload();
}
},
error: function() {
alert("Something went wrong.");
},
});
}
</script>


That should upload the photo.






share|improve this answer














You need to do some special "things" to upload files via AJAX. You need to create a FormData object and manually add the file data to it, and also set the contentType, processData and cache options of your AJAX call to false. Your javascript should look like this:



<script>
function createDocsVerify() {
var formdata = new FormData();
var file = jQuery('#photo1').prop('files')[0];
formdata.append('photo1', file);

//Ajax call Start Here
jQuery.ajax({
url: '/myproject/adminseller/sellerdocsverify.php',
method: 'POST',
cache: false,
contentType: false,
processData: false,
data: formdata,
success: function(data) {
if (data != 'passed') {
jQuery('#modal_errors_3').html(data);
}
if (data == 'passed') {
jQuery('#modal_errors_3').html("");
location.reload();
}
},
error: function() {
alert("Something went wrong.");
},
});
}
</script>


That should upload the photo.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 7 at 18:47

























answered Nov 7 at 18:35









José A. Zapata

737212




737212








  • 1




    What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
    – Jay Blanchard
    Nov 7 at 18:38










  • This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
    – José A. Zapata
    Nov 7 at 18:42










  • Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
    – Jay Blanchard
    Nov 7 at 18:44










  • Ok, there you go.
    – José A. Zapata
    Nov 7 at 18:48










  • @Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
    – Sarah
    Nov 7 at 18:52














  • 1




    What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
    – Jay Blanchard
    Nov 7 at 18:38










  • This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
    – José A. Zapata
    Nov 7 at 18:42










  • Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
    – Jay Blanchard
    Nov 7 at 18:44










  • Ok, there you go.
    – José A. Zapata
    Nov 7 at 18:48










  • @Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
    – Sarah
    Nov 7 at 18:52








1




1




What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
– Jay Blanchard
Nov 7 at 18:38




What "special things" should the OP do? A good answer will always have an explanation of what was done and why it was done in such a manner, not only for the OP but for future visitors to SO.
– Jay Blanchard
Nov 7 at 18:38












This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
– José A. Zapata
Nov 7 at 18:42




This is one of those instances where I know what to do, but not exactly the why. To upload files I know you have to use the FormData object, I know you have to set the cache, processData and contentType options to false, etc., but that's it.
– José A. Zapata
Nov 7 at 18:42












Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
– Jay Blanchard
Nov 7 at 18:44




Then explain that in your answer. Right now the OP is having to guess what you did and what you changed, provided they know how to diff code.
– Jay Blanchard
Nov 7 at 18:44












Ok, there you go.
– José A. Zapata
Nov 7 at 18:48




Ok, there you go.
– José A. Zapata
Nov 7 at 18:48












@Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
– Sarah
Nov 7 at 18:52




@Jose Thanks for the answer but in php it says $required = array( 'photo1' => 'Please select Photo 1', ); Please select photo1 and file is not an image while now I am getting filename and fileext is: png
– Sarah
Nov 7 at 18:52


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53194822%2fproblem-with-uploading-a-image-via-ajax-call-in-php%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()