index.html 複製程式碼 程式碼如下: 無刷新上傳檔案 "utf-8" /> <BR>function startUpload() { <BR>document.getElementById('processing').innerHTML = 'loding...'; <BR>return true; <BR>} <BR> function stopUpload(rel){ <BR>var msg; <BR>switch (rel) { <BR>case 0: <BR>msg = "上傳成功"; <BR>break; <BR>case 1: <BR>msg = "上傳的檔案超過限制<BR><BR>; case 2: <BR>msg = "只能上傳圖片檔"; <BR>break; <BR>default: <BR>msg = "上傳圖片檔案"; <BR>break; <BR>default: <BR>msg = "上傳圖片檔案」; <BR>break; <BR>default: <BR>msg = "上傳圖片檔案script> <BR> <BR><body> <BR><div> <BR><div> <BR><form action="upload.php" method="post" enctype="multipart/form-data" target=" form-target" name="MAX_FILE_SIZE" value="1000000" /> <BR><input type="file" name="myfile" /> <BR><input type="submit" name="sub" value="upload" / > <BR> <BR><iframe name="form-target"> <BR> <BR> <BR><p><span>upload.php <U><p>程式碼如下:<BR><BR><BR><?php <BR>sleep(2); <BR>$fileTypes = array('jpg','png','gif','bmp'); <BR>$result = null; <BR>$uploadDir = '. /upfiles'; <BR>$maxSize = 1 * pow(2,20); <BR>if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['sub'])) { <BR>$myfile = $ _FILES['myfile']; <BR>$myfileType = substr($myfile['name'], strrpos($myfile['name'], ".") + 1); <BR>if ($myfile['size'] > $maxSize) { <BR>$result = 1; <BR>} else if (!in_array($myfileType, $fileTypes)) { <BR>$result = 2; <BR>} elseif (is_uploaded_file($myfile['tmp_name'))] toFile = $uploadDir . '/' . $myfile['name']; <BR>if (@move_uploaded_file($myfile['tmp_name'], $toFile)) { <BR>$result = 0; <BR>} else { <BR>$result = -1; <BR>} <BR>} else { <BR>$result = 1; <BR>} <BR>} <BR>?> <BR><script type="text/javascript"> <BR>window.top.window.stopUp(<?php echo; >); <BR> 以上就介紹了五年級上冊語文課件 PHP無刷新上傳文件實現代碼,包括了五年級上冊語文課件方面的內容,希望對PHP教程有興趣的朋友有所幫助。 🎜