Timthumb getting error: Could not create the file cache directory - php

Recently I am working on a project, where I need an image resizer script. I searched many times on Google, but I did not found any good script. I just saw one named timthumb, but I'm still getting problems.
I am using this code snippet for trimming the image:
<img src="trim.php?src=/ahsan.jpg&h=150&w=150"/>
But when I run the file, I get an error. I could not found any resized image, but just a blank page. Also, I got this error:
Could not create the file cache directory
How to fix it?

This is most likely because your file cache directory permissions do not allow TimThumb to write to it. To find your file cache directory go into the timthumb configuration file and look for "FILE_CACHE_DIRECTORY" constant.
Modify the permissions on that folder and make sure it is writable by the user executing the script

Like A_funs answered, you should have the "cache" folder. If you don't have, create it on your root folder or aside your file.
I managed to solve the problem giving permission to this cache folder through 770 permission.

Related

Error Uploading images in drupal

I was trying to upload a custom logo to my drupal site which runs on IIS 8 with PHP.
I got the following upload error :
" Warning: move_uploaded_file(temporary://logo.png): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in drupal_move_uploaded_file() (line 1642 of C:\inetpub\wwwroot\drupalfull\includes\file.inc).
Warning: move_uploaded_file(): Unable to move 'C:\Windows\Temp\php25C3.tmp' to 'temporary://logo.png' in drupal_move_uploaded_file() (line 1642 of C:\inetpub\wwwroot\drupalfull\includes\file.inc).
File upload error. Could not move uploaded file."
Please help me. I have set both read and write permissions on IIS but still it does not work.
Create sites/default/files/tmp folder and give full permissions (777) and change 'Temporary directory' at admin/config/media/file-system.
I think it fixes yout problem.
Regards.
If you are running ISS8 (web server) then the file path is different then the default for Unix.
Make sure you have the temporary folder setup correctly on your settings in Drupal and the folder has write permissions.
You can follow this article at step 5 and 6.
Create the folder:
Drupal uses the Sites\Default\Files directory to store temporary files and therefore must be able to write and modify files in this folder.
Create the folder:
C:\inetpub\wwwroot\Drupal>md sites\default\files
http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/install-drupal-on-iis
Your problem is most likely the permission problem inside drupal. Since you are using windows system, you need to make sure the folder sites/default/files have writable permission for the IIS server. Config the permission to be writable for all user and see if it is working and then limit the permission step by step until you feel comfortable.
I'm going to put another answer in here because I guarantee I'm going to forget how I fixed it!
Basically, on Windows, the default upload folder for PHP is C:\Windows\Temp. As part of the Drupal upload, it moves files from the PHP upload folder to the Drupal Temporary//: folder. There is an issue however in PHP whereby the PHP executable needs read permission to the full path to the uploaded files, so C:\Windows\Temp. If this is not given, it will error out and the file will not be moved.
Details are at http://php.net/manual/en/function.realpath.php which is a function call made deep in Drupal's upload file code.
My fix was to create a folder elsewhere, say C:\PHPTemp, and modify PHP's settings (session.save_path and upload_tmp_dir) to point to this folder instead. After giving IIS_IUSRS full control (overkill? probably!), I was then able to upload images!

cannot includ a existing file - failed to open stream: Permission denied

this is not a duplicate question, I read all related questions, and didn't find my answer.
I want to include a file that exists :
/var/www/html/monitor/protected/extensions/curl/curl.php
and my code is :
include('/monitor/protected/extensions/curl/curl.php');
and I'm getting this error :
include(/var/www/html/monitor/protected/extensions/curl/curl.php): failed to open stream: Permission denied
and the file has 777 permission.
My question is :
is it possible that a file exists and have a 777 permission and a proper chown AND still give this error?
Update : I had used all three possible ways :
include('/monitor/protected/extensions/curl/curl.php');
include('monitor/protected/extensions/curl/curl.php');
include('/var/www/html/monitor/protected/extensions/curl/curl.php');
Im using php 5.3
Note: when including another file in the same directory, it includes without any problem
I know this is late, but I just want to confirm Alireza Fallah's answer. This also worked for me. It looks like it has to be the original owner. So unzip/unrar the php files on the same machine you want to use it on. Hope this helps!
You're using the wrong path. If the file exists at
/var/www/html/monitor/protected/extensions/curl/curl.php
Then you should include that exact string.
include('/var/www/html/monitor/protected/extensions/curl/curl.php');
/ means the root of the file system. You get permission denied because you most certainly don't have permission to / and /monitor doesn't exist
Alternatively you can include it relatively. By dropping the first / you would do:
include('monitor/protected/extensions/curl/curl.php');
This will work if the running script is also in /var/www/html.
I think you're getting confused at the difference between the HTTP path and the system path. PHP files are included from the system path and should be referenced by the system path.
I deleted the file, and created again, and my problem solved.
the original file was downloaded from the internet and unzipped from a zipped file.
I think there was a problem with creating the file by original author.
This is very odd! but it worked

Drupal 7 error: The file could not be created

I move drupal 7 from server(live Site) to my localhost(xampp). I change settings.php(files/defualt/settings.php) for database connection and remove cache from mysql database. now in load index, i see my website without css design(only text) and see this error :
**Error message**:
The file could not be created.
The file could not be created.
The file could not be created.
The file could not be created.
The file could not be created.
I think drupal not create css/js compression files. How To Fix This Error? Thanks For Any Help.
While running MAMP
found answer from here:
http://drupal.org/node/581558#comment-6202892
Went to: admin/config/media/file-system
changed "/tmp/php" to "tmp/php" and problem was solved.
similar to the other answer it was a problem with my file system setup. The tmp directory in my live site is in a folder outside the public_html folder.
so I just created a new tmp directory inside my directory structure
and
went to admin/config/media/file-system and
set the tmp folder to point to that new tmp folder.
It seems a permissions problems, after you cleared the drupal cache, all the css and js files needs to be recreated in sites/default/files (or sites/yourdomain/files), check the web users has permission to write in this directory.
You need to give your "Temporary directory" to write permission. From admin-> config -> file system
First Check whether the Temp Folder is available in your sites/default/files directory or not.
If Temp Folder is not available then create the Folder and give the correct access permission to that folder.
If Temp Folder already available there then check the permission of the folder.

Wordpress Error: A TimThumb error has occured

I've encountered an error after installing wordpress onto a new domain.
I've contacted the theme developer and have had no luck resolving the issue.
I receive the following error when i copy the image link:
Warning: touch() [function.touch]: Utime failed: Permission denied in /home/domain/public_html/wp-content/themes/folioway/core/thumb.php on line 190
Warning: Cannot modify header information - headers already sent by (output started at /home/domain/public_html/wp-content/themes/folioway/core/thumb.php:190) in /home/domain/public_html/wp-content/themes/folioway/core/thumb.php on line 413
A TimThumb error has occured
The following error(s) occured:
Could note create the index.html file.
Query String : src=/wp-content/uploads/2012/03/CoffeetabeBox-custom_web1.jpg&w=187&h=187&zc=1&q=90
TimThumb version : 2.8.2
I have not modified anything else aside from some CSS.
The thumbnails do not appear on the pages, however, the images do appear in lightbox.
I have set the permissions to the cache folder to 777, but this has not resolved the issue.
Any help would be greatly appreciates. Thanks.
It happened to me too, and this is the second time!
If you don't have time to discover why, but you want to keep it working, just rename, or delete your /cache folder; then, create a brand new /cache folder, set permissions to 777, and it will work again.
I found that the cache folder this is referring to is the one within the same folder as timthumb.php - find that file and the related cache folder and give the cache folder 777 permissions.
if you are on a linux based server,
first find the FILE_CACHE_DIRECTORY from the config file by (ex. in linux server open the file in vi commond)
vi /system/web/esupu/wp-content/themes/gadgetry-parent/framework/timthumb/timthumb-config.php
it could be like
define('FILE_CACHE_DIRECTORY', '../../cache/');
SO we change the cache folder ownership to user "www-data" which is the default user for Apache web server which runs this php codes,
sudo chown -hR www-data:www-data /system/web/esupu/wp-content/themes/gadgetry-parent/cache/
also, now better check if folder can be writable too (chmod permissions to 777)
Instead of using 777 as others have suggested, use 755 to the /cache folder.
I just delete the cache folder and refresh the page where code was, it started working.
I think it is the problem of file permission.
Headers already sent is usually a symptom of whitespace either at the beginning or the end of the file - check timthumb.php and make sure you have no blank lines or space either before the
The other possibility is that /wp-content/uploads/ is not writable by the web server, but I'd bank on the first one being the cause.
I added this to a php.ini file:
display_errors = Off
display_warnings = Off
output_buffering = On
TimThumb is a separate open source project that is used by many WP plugins.
If updating folder permissions doesn't work for you, another solution which worked for me was to update the plugin's TimThumb script with the most recent version. You can download it here:
https://timthumb.googlecode.com/svn/trunk/timthumb.php
In my case this file was in wp-content/plugins/events-manager/includes/thumbnails
For others that have this issue when using the FiatLux Wordpress Theme, as I am here is the solution:
Open FTP like Filezilla
Navigate to yoursite/wp-content/themes/fiatlux/includes*
Delete the cache folder
Recreate the cache folder, with permission setting 755
Download the updated timthumb.php file from GitHub and replace (I renamed the old one timthumb.old to test
If you use a Media server/ CDN, then be sure to add that site to the $ALLOWEDSITES array in TimThumb.php file
*If using another Wordpress theme, then find the TimThumb.php file and corresponding cache folder in that theme/ plugins folder in wp-content
in
src=/wp-content/uploads/2012/03/CoffeetabeBox-custom_web1.jpg&w=187&h=187&zc=1&q=90
try put a '?' between .jpg and &w, so it will be like this
src=/wp-content/uploads/2012/03/CoffeetabeBox-custom_web1.jpg?&w=187&h=187&zc=1&q=90

PHP - uploading images not working. Folder owner issue

I have one issue in one of my site. When I upload an image, it creates a folder and then uploading images inside the folder. Creating folder is working fine for me, but image can not be uploaded. move_uploaded_files is returning false without any error message.
When I checked manually, All folders have proper 777 permission. When folder is created by my code, owner is "apache".
But, when I created a folder manually via ftp, then owner is my username "aayushi", for this folder, upload image is working fine.
Any idea how can I fix the issue? OR how can I give rights to "apache" owner to upload images...
Thanks in advance.
When a folder is created, the owner will be the user who created the folder - in your ftp client, this is the user you logged in as; in PHP, this will be the user the PHP script runs as (in this case, the apache user). Most likely, your problem is the umask setting of Apache when it creates these folders. Setting the umask is covered in the PHP manual.
If you can find a copy of Sklar and Trachtenberg's "PHP Cookbook" somewhere, check out Recipe 19.11 ("Making New Directories") for a bit more discussion on how this works - there may be other tutorials as well, but this is one I found to be pretty clear.

Categories