PHPExcel中open_basedir restriction in effect的解決辦法
Jun 13, 2016 pm 12:29 PM
PHPExcel中open_basedir restriction in effect的解決方法
用PHPExcel做導(dǎo)出execl的時(shí)候發(fā)現(xiàn)在本地沒有問題,但是把網(wǎng)站傳到租用的服務(wù)器的時(shí)候就報(bào)錯(cuò),具體如下:
Warning: realpath() [function.realpath]: open_basedir restriction <span style="color: #0000ff;">in</span> effect. File(/tmp) <span style="color: #0000ff;">is</span> not within the allowed path(s): (/data/home:/usr/home:/data/home/tmp:/usr/home/tmp:/<span style="color: #0000ff;">var</span>/www/disablesite) <span style="color: #0000ff;">in</span> /data/home/【服務(wù)器名稱】/htdocs/【項(xiàng)目地址】/Classes/PHPExcel/Shared/File.php on line <span style="color: #800080;">136</span><span style="color: #000000;"> 找到對(duì)應(yīng)的File.php的136行,只是sys_get_temp_dir方法的最后一行,查閱網(wǎng)上的方法直接把該方法給替換掉就好了。 </span>
代碼如下:?
<span style="color: #0000ff;">public static function sys_get_temp_dir()<br>{<br>if</span> (ini_get(<span style="color: #800000;">'</span><span style="color: #800000;">upload_tmp_dir</span><span style="color: #800000;">'</span>)!==<span style="color: #0000ff;">false</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">if</span>($temp = ini_get(<span style="color: #800000;">'</span><span style="color: #800000;">upload_tmp_dir</span><span style="color: #800000;">'</span><span style="color: #000000;">)) { </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (file_exists($temp)) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> realpath($temp); } } } </span><span style="color: #0000ff;">if</span> ( !function_exists(<span style="color: #800000;">'</span><span style="color: #800000;">sys_get_temp_dir</span><span style="color: #800000;">'</span><span style="color: #000000;">)) { </span><span style="color: #0000ff;">if</span> ($temp = getenv(<span style="color: #800000;">'</span><span style="color: #800000;">TMP</span><span style="color: #800000;">'</span><span style="color: #000000;">)) { </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (file_exists($temp)) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> realpath($temp); } </span><span style="color: #0000ff;">if</span> (($temp!=<span style="color: #800000;">''</span>) &&<span style="color: #000000;"> file_exists($temp)) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> realpath($temp); } } </span><span style="color: #0000ff;">if</span> ($temp = getenv(<span style="color: #800000;">'</span><span style="color: #800000;">TEMP</span><span style="color: #800000;">'</span><span style="color: #000000;">)) { </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (file_exists($temp)) { </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> realpath($temp); } } } <br>}</span>
?

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In computers, temp means "temporary folder", which contains many temporary files; its function is to temporarily save the user's work results in the application to prevent losses caused by accidents. Deleting temp files can free up hard disk storage space, but it will be slower to open the application for the first time after deletion.

How to convert php blob to file: 1. Create a php sample file; 2. Through "function blobToFile(blob) {return new File([blob], 'screenshot.png', { type: 'image/jpeg' })} ” method can be used to convert Blob to File.

Use Java's File.length() function to get the size of a file. File size is a very common requirement when dealing with file operations. Java provides a very convenient way to get the size of a file, that is, using the length() method of the File class. . This article will introduce how to use this method to get the size of a file and give corresponding code examples. First, we need to create a File object to represent the file we want to get the size of. Here is how to create a File object: Filef

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

The usage of return in C language is: 1. For functions whose return value type is void, you can use the return statement to end the execution of the function early; 2. For functions whose return value type is not void, the function of the return statement is to end the execution of the function. The result is returned to the caller; 3. End the execution of the function early. Inside the function, we can use the return statement to end the execution of the function early, even if the function does not return a value.

Use Java's File.renameTo() function to rename files. In Java programming, we often need to rename files. Java provides the File class to handle file operations, and its renameTo() function can easily rename files. This article will introduce how to use Java's File.renameTo() function to rename files and provide corresponding code examples. The File.renameTo() function is a method of the File class.

The temp folder is our temporary file storage location. The system will save temporary files to this folder. If there are too many temporary files, especially when the temp folder is on the system disk, it is likely to affect the system running speed. We can solve the problem by changing the temp location. Let’s take a look below. Tutorial on changing the location of win7temp 1. First, right-click "Computer" and open "Properties" 2. Click "Advanced System Settings" on the left 3. Click "Environment Variables" below 4. Select "temp" and click "Edit" 5. Then change Just change the "Variable Value" to the path that needs to be changed.

Use java's File.getParent() function to get the parent path of a file. In Java programming, we often need to operate files and folders. Sometimes, we need to get the parent path of a file, which is the path of the folder where the file is located. Java's File class provides the getParent() method to obtain the parent path of a file or folder. The File class is Java's abstract representation of files and folders. It provides a series of methods for operating files and folders. Among them, get
