I'm working with fpdf libray for providing pdf files. A part of my project consists of using this library to generate pdf files for consumers.
We are working with a server test under "ovh". The arborescence of my space in "ovh" is : /www/betatest.
A folder named upload which contains factures's folder where all the facture's pdf files will be there.
So, when i try to generate a pdf file inside the factures folder, in a web browser it displays me :
Warning: fopen(upload/factures/facture_98.pdf) [function.fopen]: failed to open stream: Success in /homez.742/coplayer/www/betatest/library/fpdf/fpdf.php on line 1025
FPDF error: Unable to create output file: upload/factures/facture_98.pdf.
I tried a lot of things that i found in this web site but does not work.
Please help me. Thank's a lot! :)
Make sure the directory have at least a 755. Also, use $_SERVER['DOCUMENT_ROOT'] with your path to target the good directory :
$nomFacture = $_SERVER['DOCUMENT_ROOT']."upload/factures/facture_".$idFacture.".pdf";
That will produce something like
/homez.742/coplayer/www/betatest/upload/factures/facture_12.pdf
Make sure you have not sending to output something else (like echo, var_dump, etc.) before generating PDF with Output("path_file", "F"). It is mandatory.
make sure that file upload/factures/facture_98.pdf is not open anywhere when you run script. if it's open somewhere else then TCPDF can't open it.
Related
I'm using Laravel to build an web application. I want to create an PDF document, therefore I use the DOMPDF class by BarryVDH. (https://github.com/barryvdh/laravel-dompdf/tree/0.4)
In my view, when I use an CSS asset, I get the following error:
file_put_contents(XXXX/app/storage/fonts/6fb68711b6675ac0a3fd0da8c654f06d.ttf): failed to open stream: No such file or directory
Does anyone knows how I can fix this?
There is definitly a problem with the destination folder path.
change your path
XXXX/app/storage/fonts/
or check maybe u don't have that directory or don't have file in that directory!
I need to extract from zip file data.zip only one file for example 188139.xml
File contains folder with more than 88000 files. But after open - it shows me 21797 files and can't open file with big index (which is truly there). But opens 1.xml, 200.xml etc.
So it looks like limitation. Is there any suggestions how to open needed file?
Looks like it a bug of library. Fixed with alternative use of execute() function.
I tried to reorganise my facebook application files into better folders and now when I try to load my application on facebook it throws the following error:
Warning: require_once(../scripts/mysql_connect.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\<root folder>\Model\Database.php on line 3
Fatal error: require_once() [function.require]: Failed opening required '../scripts/mysql_connect.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\<root folder>\Model\Database.php on line 3
The second error is a result of the failure of the first one I think. The weird thing is that my program works perfectly fine when I'm accessing through the localhost url in the browser but when I run it through facebook it throws this error.
In my root folder I have a "Model" folder where the Database.php file is kept and a "scripts" folder where the mysql_connect.php file is kept. I have tried clearing my cache on the browser and using private browsing but it is still throwing this error.
Does anyone know what could be wrong?
EDIT: Sorry this does not seem to be working in localhost either now! One thing I think is weird is that it says "failed to open stream : NO SUCH FILE OR DIRECTORY IN" and then lists the database.php path. Why is it looking in there?
I use the line require_once('../scripts/mysql_connect.php'); at the top of my Database.php file to include it.
It seems that on the server there is a different working directory. Something like the following owuld be a quick fix
dirname(__FILE__) . '/../scripts/mysql_connect.php'
Ok I've fixed this, but I'm still unsure why it was a problem. In my root folder I have two folders: scripts, and Model. I have a database.php file in my Model folder which has the following line of code in:
require_once('../scripts/mysql_connect.php');
For some reason this did not work, but by replacing the line with:
require_once('/scripts/mysql_connect.php');
This started working again! Just thought I would post the solution. Does anyone know why the other way failed? I thought the ".." just makes it go up one level in the folder hierarchy i.e. to the root folder in this case, and then follow the path which would have taken it to the file...
EDIT: This appears to only have solved it for localhost and not through Facebook...
Do you have permission to edit your php.ini file? One solution would be to find the line with the include path (you'll notice it has C:\xampp\php\PEAR in there already). Include the full path to the "scripts" folder you're referencing, then you can change the php code to read:
require_once('mysql_connect.php');
PHP will be able to find this file since it's in the include path. Just make sure that if you start adding several include paths that you shouldn't have a file named mysql_connect.php in two or more of the different include paths because you'll most likely get errors. Hope this helps. It definitely makes for some cleaner code.
i want to include a php file .module file like this using hook_init
function drupsocial_init() {
require_once base_path().(drupal_get_path('module', 'drupsocial') . '/libraries/dsinvoke.php');
}
but showing this error
Fatal error: require_once() [function.require]: Failed opening required '/drupal6/trunk/sites
/all/modules/drupsocial/libraries/dsinvoke.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs
\drupal6\trunk\sites\all\modules\drupsocial\drupsocial.module on line 32
how can i include such file
You normally can include any file if you know the full path of the file and the file is accessible. Check the path to the library, correct it and you should not have any problem.
Start with the full path to the file first. If that works, you can think about using a dynamic path to the file.
why drupal trying to load the file in the trunk directory ? are you working on a svn repo ? i think there's something wrong with that path.
I also suggest you to check permissions
Hope this helps
i have found some pdf file geneartion program in php. When i run it i get the following error Warning:
Warning: include(helveticab.php) [function.include]: failed to open stream: No such file or directory in E:\wamp\www\raj19\fpdf.php on line 789
Warning: include() [function.include]: Failed opening 'helveticab.php' for inclusion (include_path='.;C:\php5\pear') in E:\wamp\www\raj19\fpdf.php on line 789
FPDF error : Could not include font metric file
I think the fpdf.php is missing .I have searched on their site but i could not find the english version. can anyone provide me full link of english version?
helveticab.php is a font definition file, which is shipped with FPDF. Get it here:
http://www.fpdf.org/
Since your code is not able to locate font library, add this line to your code.
define('FPDF_FONTPATH','fpdf/font/');
All you have to do is to copy the entire folder, and check for "fonts" one. Go inside and search for the file you're looking for.
If nothing works. Try with $font = 'fonts/arial.ttf'; and in the "fonts" folder put the TTF file. If you don't know where to get it. Search in your explorer "fonts" and get the TTF file by dragging it to the fonts folder or copying it.
If doens't works, copy the code line where you're trying to call the font file.
Depends on where the library is in the root directory. if Is in the same place just use
$str = 'fpdf.php';
require($str);
if your output is in a directory called fpdf and your php output is in another directory i.e. mydoc, you need to go up one step
$str = '../fpdf.php';
if your php output is down 2 steps i.e. root/myfolder/mydoc/output.php then you need to up two steps $str = '../../fpdf/fpdf.php'; i'm assuming that you have your fpdf library in the folder root/fpdf/fpdf.php