Copy CodeThe code is as follows:
No refresh upload file
br>
PHP code
!--? php sleep (2);
$fileTypes = array (' jpg ', ' png ', ' gif ', ' bmp ');
$result = null;
$uploadDir = './upfiles ';
$maxSize = 1 * POW (2,20);
if ($_server[' request_method '] = = ' POST ' && isset ($_post[' Sub ')) {
$myfile = $_files[' myfile '];
$myfileType = substr ($myfile [' name '], Strrpos ($myfile [' name '], ".") + 1);
if ($myfile [' Size '] > $maxSize) {
$result = 1;
} else if (!in_array ($myfileType, $fileTypes)) {
$result = 2;
} elseif (Is_uploaded_file ($myfile [' tmp_name ')) {
$toFile = $uploadDir. '/' . $myfile [' name '];
if (@move_uploaded_file ($myfile [' Tmp_name '], $toFile) {
$result = 0;
} else {
$result =-1;
}
} else {
$result = 1;
}
}
?>
The above describes the use of iframe PHP using IFRAME to implement the non-flush file upload function code, including the use of IFRAME content, I hope the PHP tutorial interested in a friend helpful.