Home >Backend Development >PHP Tutorial >Thinkphp3.2 Linux下缩略图生成失败,该怎么处理

Thinkphp3.2 Linux下缩略图生成失败,该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:03:35861browse

Thinkphp3.2 Linux下缩略图生成失败
代码在本地运行正常,部署到Linux就不好使了。
前端代码:

<br />	<script type="text/javascript"><br />	$(function() {<br />		$("#file_upload").uploadify({<br />	        height        : 30,<br />	        swf           : '{$Think.const.SITE_URL}public/GoodsUploadify/uploadify.swf',<br />	        uploader      : '{:U("Goods/GoodsUploadify")}',<br />	        width         : 120,<br />	      	//允许上传的文件后缀<br />	        'fileTypeExts':'*.jpg;*.jpge;*.gif;*.png',<br />	        'multi'       : false, //是否支持多文件上传 <br />	        'simUploadLimit' : 1, //一次同步上传的文件数目<br />	        'sizeLimit'      : 31457280, //设置单个文件大小限制<br />	        'queueSizeLimit' : 1, //队列中同时存在的文件个数限制<br />	        //'buttonImage':'/public/uploadify_shop/upbutton.jpg',//浏览按钮的背景图片路径<br />	        'formData': { 'sessionid': '<?php echo session_id();?>'}, <br />	        'onUploadSuccess' : function(file, data, response) {<br />	        	var data = $.parseJSON(data);<br />            $('#images').attr('src','{$Think.const.SITE_URL}public/GoodsImages/'+data['url']);<br />            $('#original_img').val(data['url']);<br />	        },<br />	    });<br />	});<br />	</script><br />


php端代码:
<br />public function GoodsUploadify() {<br />		if (! empty ( $_FILES )) {<br />			if (isset ( $_POST ['sessionid'] )) {<br />				session_id ( $_POST ['sessionid'] );<br />				session_start (); // 注意此函数要在session_id之后<br />			}<br />			import ( 'Org.Net.UploadFile' );<br />			$upload = new \UploadFile ();<br />			$upload->maxSize = 3292200;<br />			$upload->allowExts = explode ( ',', 'jpg,gif,png,jpeg' );<br />			$upload->savePath = "./public/GoodsImages/";<br />			// 设置需要生成缩略图,仅对图像文件有效<br />			$upload->thumb = true;<br />			// 设置需要生成缩略图的文件后缀<br />			$upload->thumbPrefix = 'z_,s_'; // 生产2张缩略图<br />			                                // 设置引用图片类库包路径<br />			$upload->thumbMaxWidth = '520,225';<br />			// 设置缩略图最大高度<br />			$upload->thumbMaxHeight = '520,225';<br />			// 设置上传文件规则<br />			$upload->saveRule = 'uniqid';<br />			// 删除原图<br />			// $upload->thumbRemoveOrigin = true;<br />			$this->ajaxReturn ( 1, 'json' );<br />			if (! $upload->upload ()) { // 上传错误提示错误信息<br />				$this->ajaxReturn ( 2, 'json' );<br />				$this->ajaxReturn ($upload->getErrorMsg (), 0, 'json' );<br />			} else { // 上传成功 获取上传文件信息<br />				$this->ajaxReturn ( 3, 'json' );<br />				$info = $upload->getUploadFileInfo ();<br />				$temp_size = getimagesize ( "./public/GoodsImages/" . $info ['0'] ['savename'] );<br />				if ($temp_size [0] < 100 || $temp_size [1] < 100) { // 判断宽和高是否符合要求<br />					$this->ajaxReturn ( 0, '图片宽或高不得小于100px!', 0, 'json' );<br />				}<br />				$data ['picName'] = $info ['0'] ['savename'];<br />				$data ['status'] = 1;<br />				$data ['url'] = $data ['picName'];<br />				$data ['info'] = $info;<br />				$this->ajaxReturn ( $data, 'json' );<br />			}<br />			<br />		}<br />	}<br />


其中$this->ajaxReturn ( (1/2/3), 'json' );为调试代码
可以返回1,当1注销时2和3都不返回,1,2,3都注销时,什么都不返回,
缩略图和原图都是一个路径,原图上成功说明缩略图路径没错。所以我就搞不懂了。
现在问题就是,缩略图生成失败,没有返回值,求大神帮忙,本来想把上传插件源码传上来参考的,没有上传附件功能啊,放这个框里 又太长 = =
------解决方案--------------------
if (isset ( $_POST ['sessionid'] )) {
                session_id ( $_POST ['sessionid'] );
                session_start (); // 注意此函数要在session_id之后
            }
THINKPHP 自动启用 session_start ,你自己设置的,重复了。

import ( 'Org.Net.UploadFile' );
            $upload = new \UploadFile ();

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn