$uploadDir = './Uploads';
if (!file_exists($uploadDir)) {
mkdir($uploadDir);
}
$fileName = $_FILES["myFileName"]["name"];
$fileName = iconv('UTF-8', 'GB2312', $fileName);
$uploadPath = $uploadDir . DIRECTORY_SEPARATOR . $fileName;
if (!$out = @fopen($uploadPath, "wb")) {
echo "error|创建文件失败!";
exit;
}
if (!empty($_FILES)) {
if ($_FILES["myFileName"]["error"] || !is_uploaded_file($_FILES["myFileName"]["tmp_name"])) {
echo "error|移动文件失败!";
exit;
}
if (!$in = @fopen($_FILES["myFileName"]["tmp_name"], "rb")) {
echo "error|写入文件失败!";
exit;
}
}
while ($buff = fread($in, 4096)) {
fwrite($out, $buff);
}
@fclose($out);
@fclose($in);
echo "";
上传图片(文件)代码
最新推荐文章于 2024-08-29 21:19:22 发布