放在sae上,在线生成图种。 http://tuzhong.sinaapp.com
-
- require('db.php');
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $stor = new SaeStorage();
-
-
- //确保有足够的空间
- $stor_size=$stor->getDomainCapacity($domain);//获取已用大小
- if($stor_size>=2*1000*1024*1024)
- {
- //删除2个文件
-
- }
-
-
- $bitfile = $_FILES[upfile];
- $picfile = $_FILES[uppic] ;
- if($bitfile['size'] >=1024 * 1024 * 10){
- echo '<script>alert("请上传小于10m的种子文件!")</script>';
- return ;
- }
- if(empty($picfile)){//上传了图片的话
-
- //文件类型为图片,pjpeg为ie中的jpg类型,并且文件大小不得大于10m
- if (in_array($picfile['type'], array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'))
- && $picfile['size'] <=1024 * 1024 * 10) {
- $fp = fopen($picfile['tmp_name'], "rb");
- $picdata = fread($fp, filesize($picfile['tmp_name']));
-
- }else{
- echo '<script>alert("请上传小于10m的图片!")</script>';
- return ;
- }
- }else{
- //如果没上传文件就使用这一个图片
- $picdata = $stor->read($domain,$BasePicture);
- }
- $fp = fopen($bitfile['tmp_name'],'rb');
- $bitdata = fread($fp,filesize($bitfile['tmp_name']));
-
-
- //合并的临时文件
- $fileName = md5(time()).".png";
- $filePath = SAE_TMP_PATH.$fileName;
-
- $fp = fopen($filePath,'w');
- fwrite($fp,$picdata);
- fwrite($fp,$bitdata);
- fclose($fp);
-
- //上传文件
- $url = $stor->upload($domain,$fileName,$filePath);
-
- echo "<script>window.location.href="down.php?url=$url"</script>";
-
-
- }
-
- ?>
复制代码
|