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 ();

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft