how to upload an image by javascript without submitting form in php? my requirement is to upload an image from my page without submitting the form.
index.html
<script>
function uploadme() {
$('#redactor_content').redactor({
imageUpload: 'process.php'
});
}
</script>
<body>
<form action="process.php" method="post" enctype="multipart/form-data" name="frm">
<input type="file" name="file" />
<input type="button" onclick="uploadme()" value="upload" />
</form>
</body>
<br/>
process.php
$dir = 'upload/';
$_FILES['file']['type'] = strtolower($_FILES['file']['type']);
if ($_FILES['file']['type'] == 'image/png'
|| $_FILES['file']['type'] == 'image/jpg'
|| $_FILES['file']['type'] == 'image/gif'
|| $_FILES['file']['type'] == 'image/jpeg'
|| $_FILES['file']['type'] == 'image/pjpeg') {
$file = $dir.$_FILES["file"]["name"];
move_uploaded_file($_FILES['file']['tmp_name'], $file);
}