You are on page 1of 2

<?

php /**

Program by: Sajith.M.R


contact me: admin@sajithmr.com
*/ ?>
<p>File Uploading Like Gmail. You can upload multiple files without submitting the
whole page. You can upload file like ajax. This is using iframe for file
upload</p>

<form target="hiddenframe" enctype="multipart/form-data" action="upload.php"


method="POST" name="uploadform">
<p>
<label>To:
<input name="textfield2" type="text" id="textfield2" size="60" maxlength="60" />
<br />
<br />
Subject:
<input name="textfield" type="text" id="textfield" size="60" maxlength="60" />
<br />
<br />
Attach File:
<input type="file" name="filefieldname" id="fileField"
onchange="document.uploadform.submit()"/>
</label>
</p>
<p id="uploadedfile" >
<label></label>
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</p>
<iframe name="hiddenframe" style="display:none" >Loading...</iframe>
</form>
<p>&nbsp; </p>

<?php /**

Program by: Sajith.M.R


contact me: admin@sajithmr.com
*/ ?>

<?php
$target_path = "upload/";

$target_path = $target_path . basename( $_FILES['filefieldname']['name']);

if(move_uploaded_file($_FILES['filefieldname']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}?>
<script>

parent.document.getElementById('uploadedfile').innerHTML += '<br><a
href="upload/<?php echo $_FILES['filefieldname']['name'] ?>"><?php echo
$_FILES['filefieldname']['name'] ?></a>';
</script>

You might also like