<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function clickupload() { $('#upmsg').html('กำลัง Upload รอซักครู่...'); return true ; } function uploadok(pathfile) { $('#upmsg').html(' *Upload เสร็จแล้ว'); $('#frmUpload')[0].reset(); return true ; } </script> <style type="text/css"> div#upload-file { font-size:12px; font-family: MS Sans Serif; } div#upload-file ul { list-style:none; } div#upload-file li { padding:4px; } div#upload-file label { width:80px; float:left; text-align:right; padding-right:5px; } div#upload-file span { color:#F00; } </style> </head> <body> <iframe id="uploadtarget" name="uploadtarget" src="" style="width:0px;height:0px;border:0"></iframe> <form id="frmUpload" action="upload.php" method="post" enctype="multipart/form-data" onsubmit="return clickupload();" target="uploadtarget"> <div id="upload-file"> <ul> <li><label>รูป : </label><input id="file_upload" name="file_upload" type="file"><span id="upmsg"> *ระบุไฟล์อัพโหลด</span><br></li> <li><label> </label><input type="submit" name="btnSubmit" id="btnSubmit" value="อัพโหลด" /></li> </ul> </div> </form> </body> </html>
<?php $filename = $_FILES['file_upload']['name']; $typefile = $_FILES['file_upload']['type']; $sizefile = $_FILES['file_upload']['size']; $tmpname = $_FILES['file_upload']['tmp_name']; $storefile = $filename; copy($tmpname, $storefile); unlink($tmpname); ?> <script language="JavaScript"> window.parent.uploadok('<?php echo $storefile?>'); </script>