parvez
02-21-2006, 10:27 AM
Hi,
I have a form to upload image and other text information to the server. I would like the user to be able to preview the image before uploading. I have tried to use javascript, but it only works in Internet Explorer. I have the following field in the form and the following javascript function:
<input id="inputImageFile" name="imgFile" type="file" tabindex="1" onchange="showPreview(this.value)" />
function showPreview(imgSource)
{
document.getElementById('imgPreview').src = imgSource ;
}
After a lot of googling, I realized that javascript is not supposed to handle any files from the local computer of the user because of security reason. That means, it works in Internet Explorer by accident or something...
Does anyone else have any cross platform solution for this problem ? I was thinking of using flash, where the image source will be sent to the flash file via javascript and then show the image using flash. But I haven't learned flash yet. Would this solution work ? If so, I would really appreciate it, if you could show me how. Thanks in advance to anyone for any help. :)
I have a form to upload image and other text information to the server. I would like the user to be able to preview the image before uploading. I have tried to use javascript, but it only works in Internet Explorer. I have the following field in the form and the following javascript function:
<input id="inputImageFile" name="imgFile" type="file" tabindex="1" onchange="showPreview(this.value)" />
function showPreview(imgSource)
{
document.getElementById('imgPreview').src = imgSource ;
}
After a lot of googling, I realized that javascript is not supposed to handle any files from the local computer of the user because of security reason. That means, it works in Internet Explorer by accident or something...
Does anyone else have any cross platform solution for this problem ? I was thinking of using flash, where the image source will be sent to the flash file via javascript and then show the image using flash. But I haven't learned flash yet. Would this solution work ? If so, I would really appreciate it, if you could show me how. Thanks in advance to anyone for any help. :)