header('content-type: text/html; charset=utf-8'); require "./include/init.php"; require_once './include/file.func.tool.php'; /* 文件太大会有问题! */ $file = isset($_FILES['file']) ? $_FILES['file'] : ''; /*print_r($file); var_dump($file['error']); exit; */ if ($msg = getErrorMsg($file['error'])) { echo "<script> alert('{$msg}'); history.go(-1); </script>"; exit; } else { if (!isImageByExt($file['name']) || !isImageByType($file['type'])) { echo "<script> alert('照片格式不正确,请检查!'); history.go(-1); </script>"; exit; } } $filedir = './data/images/'; $path = mk_dir($filedir) . '/' . randName() . '.' . getfileExt($file['name']); if (!move_uploaded_file($file['tmp_name'], $path)) { echo "<script> alert('对不起,服务器繁忙,请稍后再试!'); history.go(-1); </script>"; exit; } $username = trim($_POST['username']); $imagename = $file['name']; $imagepath = $path; $uptime = time() + 8 * 3600; $sql = "insert into photos (username, imagename, imagepath, uptime)" . "values ('{$username}', '{$imagename}', '{$imagepath}', '{$uptime}')";
</strong> <?php echo $file['username']; ?> <?php echo date('Y-m-d H:i:s', $file['uptime']); ?> </p> </td> </tr> <tr> <td> <p> <?php if (isImageByExt($file['filename'])) { echo "<img src = " . $file['filepath'] . " width = 100% height = 100%>"; } else { ?> <hr> <a href = "file_read.php?fid=<?php echo $file['fid']; ?> "> 阅读全文 </a> <?php } ?> </p> </td> </tr> </table>