I am trying to upload image on server using ajax post.
I am facing problem with big size images. For example i can upload 1MB
image without problem, but when i try to upload 5MB
image file $_FILES['errors']
return Please select file
message.
The ajax call i currently use.
var request = $.ajax({
url: '/uploadguides',
dataType: 'json',
cache: false,
contentType: false,
processData: false,
data: formData,
type: 'post',
async: false
});
In php.ini
i have set post_max_size = 3M
, upload_max_filesize = 64M
.
I thought it was post_max_size
limit problem i have increased it to 20M
but same result
First - I found this by Googling getting images:
https://github.com/blueimp/JavaScript-Load-Image
Second, why use AJAX? Doesn't the built-in Javascript Image set up automatically load in an image when you change the source? Like so:
var img = new Image();
img.src = "Path to image";
If you use the above - all you do is to check the width of the image in order to know it has been loaded. Just make a little function to check if the file has been loaded like so:
function checkImage()
{
if( img.width < 1 ){
setTimeout( "checkImage()", 100 );
return;
}
tellMeItIsLoaded();
}
Or take a look at this article