Put it on sae and generate the image online. http://tuzhong.sinaapp.com
-
- require('db.php');
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $stor = new SaeStorage();
-
-
- / /Make sure there is enough space
- $stor_size=$stor->getDomainCapacity($domain);//Get the used size
- if($stor_size>=2*1000*1024*1024)
- {
- //Delete 2 File
-
- }
-
-
- $bitfile = $_FILES[upfile];
- $picfile = $_FILES[uppic] ;
- if($bitfile['size'] >=1024 * 1024 * 10){
- echo '< ;script>alert("Please upload a seed file smaller than 10m!")';
- return ;
- }
- if(empty($picfile)){//If you uploaded a picture
-
- //File type is a picture, pjpeg is the jpg type in ie, and the file size must not be larger than 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("Please upload pictures smaller than 10m!")</script>';
- return ;
- }
- }else{
- //If no file is uploaded, use this picture
- $picdata = $stor->read($domain,$BasePicture);
- }
- $fp = fopen($bitfile['tmp_name' ],'rb');
- $bitdata = fread($fp,filesize($bitfile['tmp_name']));
-
-
- //Merge temporary files
- $fileName = md5(time()).". png";
- $filePath = SAE_TMP_PATH.$fileName;
-
- $fp = fopen($filePath,'w');
- fwrite($fp,$picdata);
- fwrite($fp,$bitdata);
- fclose( $fp);
-
- //Upload files
- $url = $stor->upload($domain,$fileName,$filePath);
-
- echo "<script>window.location.href="down.php? url=$url"</script>";
-
-
- }
-
- ?>
Copy code
|