<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>File Upload</title> </head> <body> </body> </html>
function processFile($files, $type) { $uploadName = null; foreach ($files as $name => $value) { $originalName = $value['name']; $arr = explode(".", $originalName); $postfix = $arr[count($arr) - 1]; $tmpPath = $value['tmp_name']; $tmpType = $value['type']; $tmpSize = $value['size']; } $newname = EhlStaticFunction::generateRandomStr(40).".".$postfix; switch ($type) { case 1 : // 处理声音文件 $destination = VIDEOUPLOADDIR.$newname; break; case 2 : // 处理图像文件 $destination = IMAGEUPLOADDIR.$newname; break; } move_uploaded_file($tmpPath, $destination); }