我遇到一个问题,我无法使用fopen创建任何文件。</ p>

我使用它作为测试:</ p>

$ myfile = fopen(“testfile.txt”,“w”)
</ code> </ pre>

此错误在NewRelic中输出(并且未创建testfile.txt):</ p>

fopen (testfile.txt):无法打开流:权限被拒绝</ p>
</ blockquote>
</ div>



I have an issue that I cannot create any files using fopen.

I am using this as a test:

$myfile = fopen("testfile.txt", "w")

and this error is output in NewRelic (and no testfile.txt is not created):

fopen(testfile.txt): failed to open stream: Permission denied

douchuang4181 环顾四周,右栏“相关”中有许多相同问题的链接。无论是Mac还是Linux。两者都是类Unix,权限系统是相同的。
3 年多之前 回复
drzip28288 它几乎是一样的。问题的根源是相同的:写入文件或目录(特别是当前目录)的权限不足。因此,检查两者的权限并使用chmod修复它们,例如chmod775/path/to/the/directory&&chmod644/path/to/the/directory/testfile.txt。毫无疑问,这是一个FAQ。
3 年多之前 回复
doubi8965 哪个用户正在运行php进程?该用户是否有权在该位置/文件夹中创建新文件?
3 年多之前 回复
duanhoupeng6642 重复的问题不是我认为不同的问题,我在Linux服务器而不是本地Mac上遇到问题。我无法创建相同的解决方案。
3 年多之前 回复
doucang6914 可能重复的PHPfopen()错误:无法打开流:权限被拒绝
3 年多之前 回复


确保你有​​权写。 如果在linux上你可以使用chmod()来设置文件的右边。</ p>
</ div>



It's because you don't have the right to open it. Make sure you have the right to write. If on linux you can use chmod() to set the the right of the file.

douqiao2008 如果要创建文件,请确保x右侧
3 年多之前 回复
dtstnjl898781429 感谢@ user7181041的回复文件testfile.txt不存在虽然所以我不知道如何设置权限,我想在我转到我的php文件(test.php)时创建它。 只有创建它才能更改权限,但不会创建:)
3 年多之前 回复
Csdn user default icon

<div class="post-text" itemprop="text"> <p>Since the title of this post is pretty much self-explanatory, I'll just jump to the code : </p> <pre><code>echo sprintf('%o', fileperms('test.txt'))."&lt;br/&gt;"; fopen("test.txt", "w"); </code></pre> <p>And with this I get : </p> <pre><code>100777 fopen(test.txt): failed to open stream: Permission denied </code></pre> <p>Any ideas ?</p> <p>Edit : Problem solved : there were access control lists on the server that were not configured correctly.</p> <p>Thanks !</p> </div>

PHP fopen()函数无法打开并且权限被拒绝

<div class="post-text" itemprop="text"> <p>Am using XAMP 1.7.3 on Macbook pro osx 10.9 Firefox browser</p> <p>Well basically i am trying to write a code asking the user to enter some information and then store the information in a .txt file using the: </p> <pre><code> $txtfile="registration.txt"; $handle=fopen($txtfile,'a'); </code></pre> <p>But I keep getting the this error message :</p> <blockquote> <p>Warning: fopen(registration.txt) [function.fopen]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 30</p> <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 31</p> <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 32</p> <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 33</p> <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 34</p> <p>Warning: fwrite() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/UserInfoAhmed.php on line 35</p> </blockquote> <p>full code is :</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;User Informations&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form method="post" action=""&gt; Name : &lt;input type="text" name="name"/&gt; &lt;br&gt; Age : &lt;input type="text" name="age"/&gt; &lt;br&gt; City : &lt;input type="text" name="city"/&gt; &lt;br&gt; Password: &lt;input type="password" name="pswrd1"/&gt; &lt;br&gt; Password: &lt;input type="password" name="pswrd2"/&gt; &lt;br&gt; &lt;input type="submit" name="submit" value"send"/&gt; &lt;form/&gt; &lt;?php if(isset($_POST['submit'])) { $name=$_POST["name"]; $age=$_POST["age"]; $city=$_POST["city"]; $pswrd1=$_POST["pswrd1"]; $pswrd2=$_POST["pswrd2"]; if($pswrd1 == $pswrd2){ if($city==dubai){ if($age&gt;18){ $txtfile="registration.txt"; $handle=fopen($txtfile,'a'); fwrite($handle, $name); fwrite($handle, $age); fwrite($handle, $city); fwrite($handle, $pswrd1); fwrite($handle,$pswrd2); } else echo "age must be &gt; 18"; } else echo "city must be dubai"; } else echo "password must identical"; echo "&lt;br&gt;"; } ?&gt; &lt;/body&gt; </code></pre> <p></p> <p>first i understood the first error message, failure to access / create the .txt file, and as i searched in this website, several ppl had the same problem, some the suggested a permission problem with the main file, and since every time i try to update the php file i get asked to enter my admin password, so i assumed the XAMP main file also protected</p> <p>i changed the file option to read &amp; write by all users, and all the folders within the main XAMP folder. but still i get asked for the password to save any changes in the php file am writing this code in, and thus i guess am still getting the same : fopen(registration.txt) [function.fopen]: failed to open stream: Permission denied in ... </p> <p>so how could i fix this ? also am wondering if the rest of error messages related to the main problem ?</p> <p>all in all, could someone tell me at least if there is a mistake in my code ?</p> </div>


<div class="post-text" itemprop="text"> <p>I'm trying to write to file, but PHP tells me that it's forbidden.</p> <p>I tried to change permissions, assigned files to group 'apache' (according to <code>&lt;?php echo whoami(); ?&gt;</code>), but it didn't work.</p> <p>Here is result of my file:</p> <pre><code>phpversion: 5.4.16 uname: Linux exists // echo file_exists($file) ? ' exists' : ' does not exist', " "; is readable // echo is_readable($file) ? ' is readable' : ' is NOT readable', " "; is NOT writable // echo is_writable($file) ? ' is writable' : ' is NOT writable', " "; Warning: fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied in /var/www/html/test/test.php on line 23 last error: array(4) { ["type"]=&gt; int(2) ["message"]=&gt; string(87) "fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied" ["file"]=&gt; string(30) "/var/www/html/test/test.php" ["line"]=&gt; int(23) } </code></pre> <p>Can you help me, please?</p> </div>

文件权限 - 访问被拒绝

<div class="post-text" itemprop="text"> <p>I am making an application in php and i have to test certain directories(lets say "abc" folder) file permissions and i have to create a new file dynamically ,lets say "file" in directory "xyz" .. I want "abc" to be readable and writable by webserver(i.e. 666) and in order to be able to create file in directory "xyz" am checking it for readable and writable mode too(i.e. 666)... And here is what it prints xyz directory - 777 abc directory - 777</p> <p>But when i try to </p> <pre><code>$data = 'Some file data'; $fh = fopen($rootdir."\\file.php","r+"); if ( !fwrite($fh,$data)) { //echo $rootdir; echo 'Unable to write the file'; } else { echo 'File written!'; } fclose($fh); </code></pre> <p>$rootdir contain address of folder "xyz" ... It shows following error</p> <p>Message: fopen(C:\inetpub\wwwroot\file.php) [function.fopen]: failed to open stream: Permission denied</p> <p>As i said C:\inetpub\wwwroot file permissions are 777.. And initially file.php don't exist but fopen will create it.. isn't it? And in case it won't, how can i create file dynamically?</p> <p>Any help ? </p> </div>



Apache用户 - 权限被拒绝

<div class="post-text" itemprop="text"> <p>I have a problem with my Apache user. He seems to have no right on linux system. I use CentOS 7, Apache 2.4.6, PHP 5.5.21. The apache user is apache:apache When I try to use <code>chmod()</code> or <code>fopen()</code> I get "Permission denied" So I have created a file named info.php :</p> <pre><code>-rwxrwxrwx. 1 apache apache 50 Jan 30 13:55 info.php </code></pre> <p>In this file I just added this line :</p> <pre><code>&lt;?php chmod("info.php", 777); ?&gt; </code></pre> <p>And the result is :</p> <pre><code>Warning: chmod(): Permission denied in /var/www/html/info.php on line 1 </code></pre> <p>So I think that the probelm is, system user Apache has no rights but I don't know how can I fix tis?</p> <p>Thanks.</p> <p><strong>EDIT :</strong> fix php code</p> </div>

aws ec2上的php文件写入权限被拒绝

<div class="post-text" itemprop="text"> <p>i tried write file on aws ec2 via php.</p> <p>use nginx and php-fpm.</p> <p>nginx www.conf</p> <pre><code>$ vi /etc/php-fpm-7.0.d/www.conf ; Start a new pool named 'www'. ; the variable $pool can we used in any directive and will be replaced by the ; pool name ('www' here) [www] ; Per pool prefix ; It only applies on the following directives: ; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' ; - 'chdir' ; - 'php_values' ; - 'php_admin_values' ; When not set, the global prefix (or @php_fpm_prefix@) applies instead. ; Note: This directive can also be relative to the global prefix. ; Default Value: none ;prefix = /path/to/pools/$pool ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. ; RPM: apache Choosed to be able to access some dir as httpd user = apache ; RPM: Keep a group allowed to write in log dir. group = apache </code></pre> <p>document root is...</p> <pre><code>$ ll total 56 drwxrwxr-x 20 apache apache 4096 Jun 12 06:34 ... ... ... </code></pre> <p>my sources and results is...</p> <p>i tried</p> <pre><code>$fileName = 'test.txt'; $contents = 'hello '; $currentPath = dirname(__FILE__); $fgc = file_get_contents($currentPath.'/'.$fileName); file_put_contents($contents, $fgc); </code></pre> <p>result</p> <blockquote> <p>Warning: file_get_contents(/xxx/test.txt): failed to open stream: No such file or directory in /xxx/test.php on line xx</p> </blockquote> <p>tried</p> <pre><code>$fp = fopen($currentPath.'/'.$fileName, "w"); fwrite($fp, $contents); fclose($fp); </code></pre> <p>result</p> <blockquote> <p>Warning: fopen(/xxx/test.txt): failed to open stream: Permission denied in /xxx/test.php on line xx</p> </blockquote> </div>


<div class="post-text" itemprop="text"> <p>In my app I'm trying to take a picture and send it over to the server coded as a String when I run it, I am able to take the picture but as soon as I click ok the app crashes and I get the following error:</p> <pre><code>E/BitmapFactory: Unable to decode stream: /storage/emulated/0/Pictures/test123.jpeg: open failed: EACCES (Permission denied) E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: info.androidhive.loginandregistration, PID: 8775 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done( at java.util.concurrent.FutureTask.finishCompletion( at java.util.concurrent.FutureTask.setException( at at android.os.AsyncTask$SerialExecutor$ at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean$CompressFormat, int,' on a null object reference at info.androidhive.loginandregistration.activity.ImageActivity$Encode_image.doInBackground( at info.androidhive.loginandregistration.activity.ImageActivity$Encode_image.doInBackground( at android.os.AsyncTask$ at at android.os.AsyncTask$SerialExecutor$  at java.util.concurrent.ThreadPoolExecutor.runWorker(  at java.util.concurrent.ThreadPoolExecutor$  at  </code></pre> <p>Heres my code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="" package="info.androidhive.loginandregistration" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="9" android:targetSdkVersion="21" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-feature android:name="android.hardware.Camera" android:required="true"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt; &lt;application android:name="" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name=".activity.LoginActivity" android:label="@string/app_name" android:launchMode="singleTop" android:windowSoftInputMode="adjustPan" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".activity.RegisterActivity" android:label="@string/app_name" android:launchMode="singleTop" android:windowSoftInputMode="adjustPan" /&gt; &lt;activity android:name=".activity.MainActivity" android:label="@string/app_name" android:launchMode="singleTop" /&gt; &lt;activity android:name=".activity.test" android:label="@string/app_name" android:launchMode="singleTop" /&gt; &lt;activity android:name=".activity.SearchActivity" android:label="MY SICK APP" android:launchMode="singleTop" /&gt; &lt;activity android:name=".activity.ImageActivity" android:label="MY SICK APP" android:launchMode="singleTop" android:largeHeap="true"/&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>-</p> <pre><code>public class ImageActivity extends Activity{ final String URL = "linktophpfile"; private Button button; private String coded_string, name; private Bitmap bitmap; private File file; private Uri uri; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.image_main); button = (Button) findViewById(; button.setOnClickListener(new View.OnClickListener(){ @Override public void onClick (View view){ Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); getUri(); i.putExtra(MediaStore.EXTRA_OUTPUT,uri); startActivityForResult(i,5); } }); } public void getUri() { String name = "test123.jpeg"; file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+ file.separator + name); uri = Uri.fromFile(file); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(requestCode==5 &amp;&amp; resultCode== RESULT_OK){ new Encode_image().execute(); } } private class Encode_image extends AsyncTask&lt;Void,Void,Void&gt; { @Override protected Void doInBackground(Void... voids) { bitmap = BitmapFactory.decodeFile(uri.getPath()); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream); bitmap.recycle(); byte[] array = stream.toByteArray(); coded_string = Base64.encodeToString(array,0); return null; } @Override protected void onPostExecute(Void aVoid) { makeRequest(); } } private void makeRequest() { RequestQueue queue = Volley.newRequestQueue(this); StringRequest request = new StringRequest(Request.Method.POST,URL, new Response.Listener&lt;String&gt;() { @Override public void onResponse(String response) { } }, new Response.ErrorListener(){ @Override public void onErrorResponse(VolleyError error){ } }){ @Override protected Map&lt;String, String&gt; getParams() throws AuthFailureError{ HashMap&lt;String, String&gt; map = new HashMap&lt;&gt;(); map.put("coded_String", coded_string); map.put("image_name", name); return map; } }; queue.add(request); } } </code></pre> <p>php code: </p> <pre><code>&lt;?php header('Content-type : bitmap; charset=utf-8'); if(isset($_POST["encoded_string"])){ $encoded_string = $_POST["encoded_string"]; $image_name = $_POST["image_name"]; $decoded_string = base64_decode($encoded_string); $path = 'images/'.$image_name; $file = fopen($path, 'wb'); $is_written = fwrite($file, $decoded_string); fclose($file); if($is_written &gt; 0) { $connection = mysqli_connect('localhost', 'username', 'password','dbname'); $query = "INSERT INTO images(name,path) values('$image_name','$path');"; $result = mysqli_query($connection, $query) ; if($result){ echo "success"; }else{ echo "failed"; } mysqli_close($connection); } } ?&gt; </code></pre> <p>Any ideas of what could be wrong? thanks</p> </div>

在Ubuntu中运行PHP程序 - fopen(“filename”,“w”):无法打开流:权限被拒绝

<div class="post-text" itemprop="text"> <p>I am using Ubuntu as my OS, and I have XAMPP in it. In the <code>htdocs</code> folder, I have created a project folder in which I have <code>index.php</code> file. Now inside the index.php, a part of the code does this:</p> <pre><code>fopen("colors_new.csv", "w"); </code></pre> <p>From the <a href="" rel="nofollow">manual</a>, </p> <blockquote> <p>'w' Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. <strong>If the file does not exist, attempt to create it.</strong></p> </blockquote> <p>But instead of the file being created, I am getting </p> <pre><code>Warning: fopen(colors_new.csv): failed to open stream: Permission denied... </code></pre> <p><strong>And when I look into the project folder, the <code>colors_new.csv</code> file is NOT created.</strong></p> <p><strong>When I run this program in another computer running Windows OS, it runs successfully. The file is successfully created.</strong></p> <p>How do I fix this problem in Ubuntu?</p> <p><strong>WHAT I TRIED:</strong></p> <p>I tried to run <strong><code>sudo chmod 777 colors_new.csv</code></strong> but I get <strong><code>chmod: can not access colors_new.csv. No such file or directory.</code></strong>. I tried this with just the file name (as shown) while the terminal WAS in the project directory; as well as by giving the full absolute path of the file. Got the same error both times.</p> <hr> <p><strong>NOTE:</strong> I have seen other questions, and as indicated above, I tried to give permissions to the file. The other questions did not solve the problem, the accepted answer below did solve it. </p> </div>


在VS2013编译器里,在debug或release模式下 //#include "stdlib.h" //#include "math.h" #include <iostream> #include<stdio.h> using namespace std; #define PI 3.14159//圆周率宏定义 #define LENGTH_NAME_BMP 30//bmp图片文件名的最大长度 errno_t err; void main() { char Filename[LENGTH_NAME_BMP]; cout << "请输入所需要读取的文件名" << endl; cin >> Filename; FILE *fpi=NULL, *fpw; //cout << fpi << endl; err = fopen_s(&fpi, Filename,"rb"); /*int i = err; cout << i << endl; cout << fpi << endl;*/ if (err == 0) { unsigned short filetype; fread(&filetype, 1, sizeof(unsigned short), fpi); if (filetype != 0x4d42) { cout << "文件不是BMP类型" << endl; return ; } } else { cout << "打开文件失败,错误代码:" << err << endl; } system("pause"); } ------------------------------------ err = fopen_s(&fpi, Filename,"rb"); err的值都非0,也就是函数运行失败。 而在debug或release的文件里的 exe里运行 就能运行成功(err的值为0,fpi也不是空指针)

HTML2PDF - fopen()无法打开流:6168行/ html2pdf / _tcpdf_5.0.002 / tcpdf.php中的权限被拒绝

<div class="post-text" itemprop="text"> <p>I got a problem with the HTML2PDF library (i use PHP with Zend Framework 2).</p> <p>I'm on a linux ubuntu dedicated server and the destination folder for my .pdf file got chmod 777. I even tried chmod 666 ... but i still get the same error :</p> <blockquote> <p>[warn] [client <em>.</em>.*.*] mod_fcgid: stderr: PHP Warning: fopen(/my_absolute_path/file.pdf): failed to open stream: Permission denied in /my_absolute_path/html2pdf/_tcpdf_5.0.002/tcpdf.php on line 6168</p> </blockquote> <p>Any answers ? Thx much</p> <p><strong>EDIT</strong></p> <p>@Novocaine88, you're right :-)</p> <p>Here is my very simple code :</p> <pre><code>// Set the file path $path = ROOT_PATH.'/data/myFolder_chmod_777/file.pdf'; // Create the pdf document require_once ROOT_PATH . '/vendor/html2pdf/html2pdf.class.php'; $pdf = new \HTML2PDF('P', 'A4', 'fr'); // Get the content $content = $this-&gt;getHtmlContent($required_param); // Forge PDF doc $pdf-&gt;WriteHTML($content); // Save doc $pdf-&gt;Output($path, 'F'); </code></pre> <p>This is (approximately) the code i get from the official site of HTML2PDF (<a href="" rel="nofollow"></a>). When i use it on my local machine, everything works fine, but on the distant server ...</p> <p><strong>SOLUTION</strong></p> <p>After reading my code a hundred times, i found the problem. This is stupid, i didn't set the path correctly.</p> <p>Here is the code :</p> <pre><code>// Set the file path $path = ROOT_PATH.'/data/folder/myFolder_chmod_777/file.pdf'; </code></pre> <p>It works now !</p> </div>

带有消息'fopen(/ tmp / ...)的SwiftMailer'ErrorException'无法打开流:权限被拒绝'

<div class="post-text" itemprop="text"> <p>I've deployed a <code>laravel</code> app on a <code>cpanel</code> <code>shared host</code>.</p> <p>When sending email usign <code>Mail</code> class, the following error occurs randomly. (sometimes the mail is sent but sometimes the error occurs) </p> <pre><code>production.ERROR: exception 'ErrorException' with message 'fopen(/tmp/e19839f1a2d67e4ab7c83a5951c31bfd/body): failed to open stream: Permission denied' in /home/ekbatana/laravel4/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php:300 </code></pre> <p>I contacted the host support they said I need to change the default temporary directory.</p> <p>In SwiftMailer package <code>lib/preferences.php</code> a variable called <code>$tmp</code> is set to <code>getenv('TMPDIR')</code> and a comment in the file says that:</p> <pre><code>// You can override the default temporary directory by setting the TMPDIR environment variable. </code></pre> <p>I tried to set the <code>TMPDIR</code> in different ways</p> <p>1) .htaccess: <code>SetEnv TMPDIR /home/.../laravel4/app/storage/my_temp</code></p> <p>2) in <code>app/start/global.php</code> and also in <code>App::before</code> callback function using <code>php putenv</code> function</p> <p>3) in <code>lib/preferences.php</code> before the line that $temp is set using <code>php putenv</code> function</p> <p>but non of them changes the path to the file that is opened and causes <code>failed to open stream: Permission denied</code> error</p> <p>the following is the <code>swiftmailer/lib/preferences.php</code></p> <pre><code>&lt;?php /****************************************************************************/ /* */ /* YOU MAY WISH TO MODIFY OR REMOVE THE FOLLOWING LINES WHICH SET DEFAULTS */ /* */ /****************************************************************************/ $preferences = Swift_Preferences::getInstance(); // Sets the default charset so that setCharset() is not needed elsewhere $preferences-&gt;setCharset('utf-8'); // Without these lines the default caching mechanism is "array" but this uses a lot of memory. // If possible, use a disk cache to enable attaching large attachments etc. // You can override the default temporary directory by setting the TMPDIR environment variable. // The @ operator in front of is_writable calls is to avoid PHP warnings // when using open_basedir $tmp = getenv('TMPDIR'); if ($tmp &amp;&amp; @is_writable($tmp)) { $preferences -&gt;setTempDir($tmp) -&gt;setCacheType('disk'); } elseif (function_exists('sys_get_temp_dir') &amp;&amp; @is_writable(sys_get_temp_dir())) { $preferences -&gt;setTempDir(sys_get_temp_dir()) -&gt;setCacheType('disk'); } // this should only be done when Swiftmailer won't use the native QP content encoder // see mime_deps.php if (version_compare(phpversion(), '5.4.7', '&lt;')) { $preferences-&gt;setQPDotEscape(false); } </code></pre> </div>

winserver2012 文件夹权限问题



<div class="post-text" itemprop="text"> <p>I am attempting to create a cronjob under the user apache, but I get permission denied errors for files that are accessed by the program. The specific file that my php script cannot access is /var/www/html/amazon/amazon_data.txt. Here is me checking the permissions, and testing to see if I can write to the file:</p> <pre><code>bash-3.2$ whoami apache bash-3.2$ ls -l /var/www/html/amazon/amazon_data.txt -rwxrwxr-- 1 apache apache 1082 Apr 3 15:43 /var/www/html/amazon/amazon_data.txt bash-3.2$ vi /var/www/html/amazon/amazon_data.txt </code></pre> <p>Now I try to run a script that tries to access the file I get this warning:</p> <pre><code>bash-3.2$ /usr/bin/php /var/www/html/amazon/amazon_inventory_sync.php PHP Warning: Module 'json' already loaded in Unknown on line 0 PHP Warning: fopen(amazon_data.txt): failed to open stream: Permission denied in /var/www/html/amazon/amazon_inventory_sync.php on line 26 Warning: fopen(amazon_data.txt): failed to open stream: Permission denied in /var/www/html/amazon/amazon_inventory_sync.php on line 26 Unable to open amazon_data.txt!bash-3.2$ </code></pre> <p>Why can I access and edit the file with the user just fine, but not in the php script when executing it via command line? There is no issue when I run the script from a browser.</p> <p>Edit: I can run it fine under the user soh, who is in the group apache. apache is also in the group apache.</p> </div>


<div class="post-text" itemprop="text"> <p>I have the error saying that permission denied. I already tried <a href="">this</a> (giving view access to the google credential), and <a href="">this</a>. And everything doesnt work. I already enable the API for the google drive and also did this :</p> <pre><code>gcloud components update gcloud auth login --enable-gdrive-access </code></pre> <p>I'm using PHP.</p> <p>Here's the Code</p> <pre><code>&lt;?php ini_set("memory_limit", "2048M"); ini_set('max_execution_time', 7200); //3600 seconds = 60 minutes if (!defined('BASEPATH')) exit('No direct script access allowed'); use Google\Cloud\BigQuery\BigQueryClient; use Google\Cloud\ServiceBuilder; use Google\Cloud\ExponentialBackoff; require 'assets/SDK/vendor/autoload.php'; //require 'assets/library/vendor/autoload.php'; require_once 'assets/library/google-api-php-client/vendor/autoload.php'; define('APPLICATION_NAME', 'asd'); define('CLIENT_SECRET_PATH', 'assets/library/auth/asd.json'); define('PROJECT_ID','qwe'); define('SCOPES', implode(' ', array( '', '', '', '') )); public function index(){ $myFile = "assets/library/auth/session_bq2.txt"; if(file_exists($myFile)){ @$fh = fopen($myFile, 'r'); // echo 'filesize '.filesize($myFile); $session = fread($fh, filesize($myFile)); fclose($fh); //echo '--refreshToken index '.$session; } $client = new Google_Client(); $client-&gt;setAccessType('offline'); $client-&gt;setClientId(''); $client-&gt;setClientSecret('asds'); $client-&gt;setState('asd'); $client-&gt;setApplicationName(APPLICATION_NAME); $client-&gt;setScopes(SCOPES); if (isset($session) &amp;&amp; $session) { //Set the new access token after authentication $client-&gt;setAccessToken($session); //json decode the session token and save it in a variable as object $sessionToken = json_decode($session); //Save the refresh token (object-&gt;refresh_token) into a cookie called 'token' and make last for 1 month setcookie('access_token', $sessionToken-&gt;refresh_token , time()+2678400); $cookie = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : ""; if(!empty($cookie)){ $client-&gt;refreshToken($cookie); } $client-&gt;setAccessToken($session); } else{ $tes = $client-&gt;getRefreshToken(); $client = new Google_Client(); $client-&gt;setAccessType('offline'); $client-&gt;setClientId(''); $client-&gt;setRedirectUri('qwe'); $client-&gt;setClientSecret('asd'); $client-&gt;setState('asd'); $client-&gt;setApplicationName(APPLICATION_NAME); $client-&gt;setScopes(SCOPES); if (isset($_GET['code'])) { $client-&gt;authenticate($_GET['code']); $myfile = fopen("assets/library/auth/session_bq2.txt", "w") or die("Unable to open file!"); $txt = json_encode($client-&gt;getAccessToken()); fwrite($myfile, $txt); fclose($myfile); header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']); } else{ $oauth2_client_id = ''; // $oauth2_redirect = 'asd'; $oauth2_redirect = 'http://' . $_SERVER['HTTP_HOST'] . 'asd'; $oauth2_server_url = ''; $query_params = array( 'response_type' =&gt; 'code', 'access_type' =&gt; 'offline', 'client_id' =&gt; $oauth2_client_id, 'scope' =&gt; SCOPES, 'redirect_uri' =&gt; $oauth2_redirect, 'state' =&gt; 'asd', 'approval_prompt' =&gt; 'force' ); $forward_url = $oauth2_server_url . '?' . http_build_query($query_params); header('Location: ' . $forward_url); } } $service = new Google_Service_Bigquery($client); $query="SELECT * FROM [queryspreadsheet] LIMIT 10"; putenv('GOOGLE_APPLICATION_CREDENTIALS='.dirname(__FILE__) . '/assets/library/auth/MyProject-f0b4007b2f57.json');//this can be created with other ENV mode server side $client-&gt;useApplicationDefaultCredentials(); $builder = new ServiceBuilder([ 'projectId' =&gt; 'asd', ]); $bigQuery = $builder-&gt;bigQuery(); $job = $bigQuery-&gt;runQueryAsJob($query); $info=$job-&gt;info(); $queryResults = $job-&gt;queryResults(); /*$queryResults = $bigQuery-&gt;runQuery( $query, ['useLegacySql' =&gt; true]);*/ // var_dump($queryResults);die; if ($queryResults-&gt;isComplete()) { $i = 0; $rows = $queryResults-&gt;rows(); foreach ($rows as $row) { $i++; $result[$i] = $row; } } else { throw new Exception('The query failed to complete'); } $i = 0; $i++; var_dump($result);die; return $result; } </code></pre> <p>Does anyone have any idea what did I miss? Thanks.</p> </div>

Fedora PHP“无法打开流:权限被拒绝”

<div class="post-text" itemprop="text"> <p>So I've got Apache on web server running Fedora. I'm trying to write into the text file.</p> <pre><code>if(!empty($_POST['versionWrite'])){ $file = fopen(APP_DIR."/resources/version.txt", "w"); fwrite($file, $_POST['versionWrite'].PHP_EOL); fclose($file); } </code></pre> <p>And when I execute the code, I get this:</p> <pre><code>Warning: fopen(/var/www/spumprnagle/resources/version.txt): failed to open stream: Permission denied in /var/www/spumprnagle/head.php on line 28 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/spumprnagle/head.php on line 29 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/spumprnagle/head.php on line 30 </code></pre> <p>This happens in every script working with files. And I have no idea what shall I do to grant Apache permissions to edit files.</p> <p>Thanks for your time :).</p> </div>


<div class="post-text" itemprop="text"> <p>I am trying to run a script which creates pages and saves them to the server but am getting a permission error on one of the files that is in the public_html directory.</p> <p>So 2 pages are created in the "pages" directory which is chmod to 0777 and they are created fine. The 3rd page is created in the "public_html" directory which fails with you do not have permission. The only way i have found to fix this is to chmod the "public_html" directory to 0770 which then everything works but i have been strongly advised by the hosting company not to do this bevause of the security risk.</p> <p>So my question is, Is there any otherway to achieve this goal? Looking into it a bit it looks like i need to give the script "user" priviliges might work but this is beyond my knowledge at the moment. I`m not even sure what the script is running as at the moment, I would guess "group" as chmoding the public_html to 0770 allows "group"</p> <p>My setup is: vps server running centos CENTOS 6.7 x86_64</p> <p>php 5, dso, Apache suEXEC on</p> <p>simplified Code i am using is:</p> <pre><code>$page_path = "/home/username/public_html/"; $loop[Html_Name] = "test.html"; $new_page_file = "test.html"; $fp = fopen($page_path.$loop[Html_Name], "w"); fwrite($fp, $new_page_file); fclose($fp); chmod($page_path.$loop[Html_Name], 0666); </code></pre> <p>Many thanks in advance.</p> </div>

无法打开流:Laravel 5.4中的权限被拒绝甚至Al文件权限也被授予使用Laravel 5.4中的存储功能的路径

<div class="post-text" itemprop="text"> <p>I am trying to upload a file into C:\Users\sandeep\maxo\storage\app\public folder in laravel 5.4. I am using the below code</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="{{ URL::to('importExcelFile') }}" class="form-horizontal" method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="import_file" /&gt; {{ csrf_field() }} &lt;br/&gt; &lt;button &gt;Import CSV or Excel File&lt;/button&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> <p>$path = $request-&gt;file('import_file')-&gt;store('public');</p> <p>is the laravel code.</p> <p>But I am getting an error like this </p> <blockquote> <p>fopen(C:\Users\sandeep\maxo\storage\app\public/K4oIHMXveyx2VChmAXAcNkTmoIXKACvqoIbbHCeB.): failed to open stream: Permission denied</p> </blockquote> <p>This is the picture of my error <a href="" rel="nofollow noreferrer">Click here</a></p> <p>But When i Upload the image its working fine</p> </div>


<div class="post-text" itemprop="text"> <p>I found the solution to fix "fopen(document.pdf): failed to open stream: Permission denied in C:\Program Files\VertrigoServ\www\Project\makePDF.php on line 8". It was suggested that to open terminal and run the command </p> <p><strong>sudo chmod filename.php</strong></p> <p>But i don't know which terminal should I open to run this command?</p> <p>Please help me. I'll be very thankful to you.</p> </div>


文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...


软件测试2小时入门,让您快速了解软件测试基本知识,有系统的了解; SQL一小时,让您快速理解和掌握SQL基本语法 jmeter性能测试 ,让您快速了解主流来源性能测试工具jmeter 测试管理工具-禅道,让您快速学会禅道的使用,学会测试项目、用例、缺陷的管理、


基于西门子S7—1200的单部六层电梯设计程序,1部6层电梯。 本系统控制六层电梯, 采用集选控制方式。 为了完成设定的控制任务, 主要根据电梯输入/输出点数确定PLC 的机型。 根据电梯控制的要求,




深度学习系列课程从深度学习基础知识点开始讲解一步步进入神经网络的世界再到卷积和递归神经网络,详解各大经典网络架构。实战部分选择当下最火爆深度学习框架PyTorch与Tensorflow/Keras,全程实战演示框架核心使用与建模方法。项目实战部分选择计算机视觉与自然语言处理领域经典项目,从零开始详解算法原理,debug模式逐行代码解读。适合准备就业和转行的同学们加入学习! 建议按照下列课程顺序来进行学习 (1)掌握深度学习必备经典网络架构 (2)深度框架实战方法 (3)计算机视觉与自然语言处理项目实战。(按照课程排列顺序即可)

图书管理系统(Java + Mysql)我的第一个完全自己做的实训项目

图书管理系统 Java + MySQL 完整实训代码,MVC三层架构组织,包含所有用到的图片资源以及数据库文件,大三上学期实训,注释很详细,按照阿里巴巴Java编程规范编写


人工智能、物联网、大数据时代,Linux正有着一统天下的趋势,几乎每个程序员岗位,都要求掌握Linux。本课程零基础也能轻松入门。 本课程以简洁易懂的语言手把手教你系统掌握日常所需的Linux知识,每个知识点都会配合案例实战让你融汇贯通。课程通俗易懂,简洁流畅,适合0基础以及对Linux掌握不熟练的人学习; 【限时福利】 1)购课后按提示添加小助手,进答疑群,还可获得价值300元的编程大礼包! 2)本月购买此套餐加入老师答疑交流群,可参加老师的免费分享活动,学习最新技术项目经验。 --------------------------------------------------------------- 29元=掌握Linux必修知识+社群答疑+讲师社群分享会+700元编程礼包。 &nbsp;


本课程适合CCNA或HCNA网络小白同志,高手请绕道,可以直接学习进价课程。通过本预科课程的学习,为学习网络工程师、思科CCNA、华为HCNA这些认证打下坚实的基础! 重要!思科认证2020年2月24日起,已启用新版认证和考试,包括题库都会更新,由于疫情原因,请关注官网和本地考点信息。题库网络上很容易下载到。


C++语言基础视频培训课程:本课与主讲者在大学开出的程序设计课程直接对接,准确把握知识点,注重教学视频与实践体系的结合,帮助初学者有效学习。本教程详细介绍C++语言中的封装、数据隐藏、继承、多态的实现等入门知识;主要包括类的声明、对象定义、构造函数和析构函数、运算符重载、继承和派生、多态性实现等。 课程需要有C语言程序设计的基础(可以利用本人开出的《C语言与程序设计》系列课学习)。学习者能够通过实践的方式,学会利用C++语言解决问题,具备进一步学习利用C++开发应用程序的基础。

微信小程序 实例汇总 完整项目源代码

微信小程序 实例汇总 完整项目源代码


&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。




限时福利1:购课进答疑群专享柳峰(刘运强)老师答疑服务 限时福利2:购课后添加学习助手(微信号:csdn590),按消息提示即可领取编程大礼包! 为什么说每一个程序员都应该学习MySQL? 根据《2019-2020年中国开发者调查报告》显示,超83%的开发者都在使用MySQL数据库。 使用量大同时,掌握MySQL早已是运维、DBA的必备技能,甚至部分IT开发岗位也要求对数据库使用和原理有深入的了解和掌握。 学习编程,你可能会犹豫选择 C++ 还是 Java;入门数据科学,你可能会纠结于选择 Python 还是 R;但无论如何, MySQL 都是 IT 从业人员不可或缺的技能! 【课程设计】 在本课程中,刘运强老师会结合自己十多年来对MySQL的心得体会,通过课程给你分享一条高效的MySQL入门捷径,让学员少走弯路,彻底搞懂MySQL。 本课程包含3大模块:&nbsp; 一、基础篇: 主要以最新的MySQL8.0安装为例帮助学员解决安装与配置MySQL的问题,并对MySQL8.0的新特性做一定介绍,为后续的课程展开做好环境部署。 二、SQL语言篇: 本篇主要讲解SQL语言的四大部分数据查询语言DQL,数据操纵语言DML,数据定义语言DDL,数据控制语言DCL,学会熟练对库表进行增删改查等必备技能。 三、MySQL进阶篇: 本篇可以帮助学员更加高效的管理线上的MySQL数据库;具备MySQL的日常运维能力,语句调优、备份恢复等思路。 &nbsp;

navicat简体中文版 绿色版 (64位)







文章目录经典飞机大战一.游戏设定二.我方飞机三.敌方飞机四.发射子弹五.发放补给包六.主模块 经典飞机大战 源代码以及素材资料(图片,音频)可从下面的github中下载: 飞机大战源代码以及素材资料github项目地址链接 ————————————————————————————————————————————————————————— 不知道大家有没有打过飞机,喜不喜欢打飞机。当我第一次接触这个东西的时候,我的内心是被震撼到的。第一次接触打飞机的时候作者本人是身心愉悦的,因为周边的朋友都在打飞机, 每

java jdk 8 帮助文档 中文 文档 chm 谷歌翻译

JDK1.8 API 中文谷歌翻译版 java帮助文档 JDK API java 帮助文档 谷歌翻译 JDK1.8 API 中文 谷歌翻译版 java帮助文档 Java最新帮助文档 本帮助文档是使用谷

Qt5.10 GUI完全参考手册(强烈推荐)





课程亮点: 课程培训详细的笔记以及实例代码,让学员开始掌握设计模式知识点 课程内容: 工厂模式、桥接模式、组合模式、装饰器模式、外观模式、享元模式、原型模型、代理模式、单例模式、适配器模式 策略模式、模板方法模式、观察者模式、迭代器模式、责任链模式、命令模式、备忘录模式、状态模式、访问者模式 课程特色: 笔记设计模式,用笔记串连所有知识点,让学员从一点一滴积累,学习过程无压力 笔记标题采用关键字标识法,帮助学员更加容易记住知识点 笔记以超链接形式让知识点关联起来,形式知识体系 采用先概念后实例再应用方式,知识点深入浅出 提供授课内容笔记作为课后复习以及工作备查工具 部分图表(电脑PC端查看):

进程监控软件 Performance Monitor中文版






2019 Python开发者日-培训



一 专题从基础的C语言核心到c++ 和stl完成基础强化; 二 再到数据结构,设计模式完成专业计算机技能强化; 三 通过跨平台网络编程,linux编程,qt界面编程,mfc编程,windows编程,c++与lua联合编程来完成应用强化 四 最后通过基于ffmpeg的音视频播放器,直播推流,屏幕录像,




机器学习实战系列套餐以实战为出发点,帮助同学们快速掌握机器学习领域必备经典算法原理并结合Python工具包进行实战应用。建议学习顺序:1.Python必备工具包:掌握实战工具 2.机器学习算法与实战应用:数学原理与应用方法都是必备技能 3.数据挖掘实战:通过真实数据集进行项目实战。按照下列课程顺序学习即可! 课程风格通俗易懂,用最接地气的方式带领大家轻松进军机器学习!提供所有课程代码,PPT与实战数据,有任何问题欢迎随时与我讨论。


原价169,限时立减100元! 系统掌握Python核心语法16点,轻松应对工作中80%以上的Python使用场景! 69元=72讲+源码+社群答疑+讲师社群分享会&nbsp; 【哪些人适合学习这门课程?】 1)大学生,平时只学习了Python理论,并未接触Python实战问题; 2)对Python实用技能掌握薄弱的人,自动化、爬虫、数据分析能让你快速提高工作效率; 3)想学习新技术,如:人工智能、机器学习、深度学习等,这门课程是你的必修课程; 4)想修炼更好的编程内功,优秀的工程师肯定不能只会一门语言,Python语言功能强大、使用高效、简单易学。 【超实用技能】 从零开始 自动生成工作周报 职场升级 豆瓣电影数据爬取 实用案例 奥运冠军数据分析 自动化办公:通过Python自动化分析Excel数据并自动操作Word文档,最终获得一份基于Excel表格的数据分析报告。 豆瓣电影爬虫:通过Python自动爬取豆瓣电影信息并将电影图片保存到本地。 奥运会数据分析实战 简介:通过Python分析120年间奥运会的数据,从不同角度入手分析,从而得出一些有趣的结论。 【超人气老师】 二两 中国人工智能协会高级会员 生成对抗神经网络研究者 《深入浅出生成对抗网络:原理剖析与TensorFlow实现》一书作者 阿里云大学云学院导师 前大型游戏公司后端工程师 【超丰富实用案例】 0)图片背景去除案例 1)自动生成工作周报案例 2)豆瓣电影数据爬取案例 3)奥运会数据分析案例 4)自动处理邮件案例 5)github信息爬取/更新提醒案例 6)B站百大UP信息爬取与分析案例 7)构建自己的论文网站案例

相关热词 c#分级显示数据 c# 不区分大小写替换 c#中调用就java c#正则表达式 验证小数 c# vscode 配置 c#三维数组能存多少数据 c# 新建excel c#多个文本框 c#怎么创建tcp通讯 c# mvc 电子病例