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 />
<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 />