AJAX upload causing HTTP Error 302 on Cloud 9


#1

Gooday, i am seeking your advice and would be grateful for any help.

I have images able to be uploaded to a workspace hosted on Cloud 9, using a HTML form set with the post method and enctype of ‘multipart/form-data’; PHP is successfully handling the image validation and move_uploaded_file() onto the server. If i try to have the image intercepted by AJAX in an effort to transmit the images asynchronously, the response always throws a HTTP 302 error. Similar AJAX code is working for non-image type POST queries to the same workspace.

Would be grateful for you advice, on how to deal with the error, and to get the AJAX posts working successfully.

Here is a copy of the AJAX call:

(document).ready(function (e) { ("#uploadimage").on(‘submit’,(function(e) {
e.preventDefault();
var urlString = “https://something.php”;
("#message").empty(); ("#spinner").show();
.ajax({ url: urlString, type: "POST", data: new FormData(this), contentType: false, cache: false, processData: false, error: function(response){ ("#spinner").hide();
if (response.status === 0) {
console.log(“ERRORS: " + response.textStatus);
}
},
success: function(data) {
("#spinner").hide(); (”#message").html(data);
}
});
}));
});