i have a problem with javascript (i am new in javascript).
i need submit picture file form to php script. But first I need to check size of the image if is need then resize this image down and then submit it resized.
i have this code but it dont submit file if it resize image so the question is why?
javascript:
Code: Select all
<!--
function submitFileForm(form)
{
form.picturefile.value = resize(form.picturefile);
document.fileform.submit();
}
function resize(which, max) {
var elem = document.getElementById(which);
if (elem == undefined || elem == null) return false;
if (max == undefined) max = 100;
if (elem.width > elem.height) {
if (elem.width > max) elem.width = max;
} else {
if (elem.height > max) elem.height = max;
}
return elem;
}
//-->
Code: Select all
<form method="POST" enctype="multipart/form-data" action="upload.php" style="margin-top: 0px;" name="fileform" >
<tr align="right" >
<td style="padding-top: 10px;padding-right: 5px;">
<input type="hidden" name="MAX_FILE_SIZE" value="2097152" />
<b>Insert file:</b> <input type="file" name="picturefile" />
</td>
</tr>
<tr align="right">
<td style="padding-top: 10px;padding-right: 5px; padding-bottom: 5px;">
<input type="submit" value="Prida? obrázok" onClick="submitFileForm()" />
</td>
</tr>
<tr>
<td style="text-align: center;padding-bottom:10px;padding-top:4px;">
</td>
</tr>
</form>
</table>