I found a great client side image resize solution:
http://www.resize-before-upload.com/
but the free version doesn't have form integration, so I copied some ajax code off the internet and integrated it into my PHP - so it
just keeps checking for a specific file to be uploaded and then the PHP just echos 'success' and if the ajax sees that it redirects to
another page to continue the process
Here's the JS (Jquery obviously)
$(document).ready(function()
{
//filecheck.php is called every 2 seconds to ask server if file has been uploaded yet
var refreshId = setInterval(function()
{
$('#Davfilecheck').load('scripts/filecheck.php');
var fc1 = new String();
fc1 = document.getElementById('Davfilecheck').innerHTML;
if (fc1 == "Success!"){
alert ("The photo has been successfully uploaded to the site. Click OK to enter details for photo");
window.location="index.php?locate=upload&filedone=yes";
}
}, 2000);
});
And here's the 'filecheck.php' code
<?php
if (file_exists('../secure/uploads/uploadfile')){echo "Success!";}
?>
This system works great with most newer browsers but when the file is uploaded in IE6 the JS doesn't seem to notice.
I will upload my main PHP script if necessary but I'm pretty sure this is the part that won't work in IE6.
Is the only option to ask the users to upgrade browser or is there a hack for getting this to work in IE6 ?
P.S. I've also noticed lately that on some browsers the code loops around a second time, causing problems. It must be terrible code - I'm sorry but my PHP coding is a lot better than my JS coding. :-D
If anybody knows a more efficient way to do this I would really appreciate it.
Thanks