php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57743 save() method does not accept relative path
Submitted: 2007-07-13 04:09 UTC Modified: 2007-07-13 04:23 UTC
From: pcdinh at gmail dot com Assigned:
Status: Not a bug Package: haru (PECL)
PHP Version: 5.2.1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 + 31 = ?
Subscribe to this entry?

 
 [2007-07-13 04:09 UTC] pcdinh at gmail dot com
Description:
------------
The save() method does not generate any file when I specify a relative file path.

Windows XP SP2
PHP 5.2.3

Reproduce code:
---------------
<?php

$doc = new HaruDoc();

$doc->setPageMode(HaruDoc::PAGE_MODE_USE_THUMBS); /* show thumbnails */

$page = $doc->addPage(); /* add page to the document */
$page->setSize(HaruPage::SIZE_A4, HaruPage::LANDSCAPE); /* set the page to use A4 landscape format */

$courier = $doc->getFont("Courier-Bold"); /* we'll use the bundled font a few lines below */

$page->setRGBStroke(0, 0, 0); /* set colors */
$page->setRGBFill(0.7, 0.8, 0.9);
$page->rectangle(150, 150, 550, 250); /* draw a rectangle */

$page->fillStroke(); /* fill and stroke it */

$page->setDash(array(3, 3), 0); /* set dash style for lines at this page */
$page->setFontAndSize($courier, 60); /* set font and size */

$page->setRGBStroke(0.5, 0.5, 0.1); /* set line color */
$page->setRGBFill(1, 1, 1); /* set filling color */

$page->setTextRenderingMode(HaruPage::FILL_THEN_STROKE); /* fill and stroke text */

/* print the text */
$page->beginText();
$page->textOut(210, 270, "Hello World!");
$page->endText();

$doc->save("./test.pdf"); /* save the document into a file */


?> 

Expected result:
----------------
test.pdf should be generated in the same directory with the PHP code file.

Actual result:
--------------
No file is generated. No error occurs.

PDF is generated when I make a change as follows:

$doc->save(dirname(__FILE__)."/test.pdf"); 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-13 04:23 UTC] tony2001 at phpclub dot net
The "./test.pdf" refers to the path relative to the current working directory. In threaded Server APIs (which is the only option on Win32) PHP does not change the working directory of the process since it would affect all threads of the process, instead it stores its current value for each thread.
Haru library because of obvious reasons does not know about it and writes to the current working directory OF THE PROCESS.
Just search your disk for test.pdf, I'm sure you'll find it in the working directory of your web-server.
Use relative paths keeping this in mind. 
No bug here.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC