0

I am using following code and getting issue if there is an space in image name. And the issue is basically file is not loading at popwerpoint slide.

like:

$shape->setPath("C:/image/abc1.jpg");  // Working fine

$shape->setPath("C:/image/abc 1.jpg"); // Not working due to space in filename

I'm using the PHPPowerPoint class for generating powerpoint slides.

How do I get this to work?

EDIT

For the benefit of roine

public function setPath($pValue = '', $pVerifyFile = true) {
    if ($pVerifyFile) {
        if (file_exists($pValue)) {
            $this->_path = $pValue;

            if ($this->_width == 0 && $this->_height == 0) {
                // Get width/height
                list($this->_width, $this->_height) = getimagesize($pValue);
            }
        } else {
            throw new Exception("File $pValue not found!");
        }
    } else {
        $this->_path = $pValue;
    }
    return $this;
}
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • It should still work "as is", even with spaces in filenames. Are you sure it's just a single space, and not two spaces? or some other invisible character like a ? – Mark Baker Aug 08 '12 at 10:49

2 Answers2

0

Try:

$shape->setPath("C:/image/abc%201.jpg");

If that works, you can use a simple string replace.

Fluffeh
  • 33,228
  • 16
  • 67
  • 80
0

Try

$file_path = "C:/image/abc 1.jpg";
$clean_file_path = str_replace(" ", "%20", "$file_path");
$shape->setPath($clean_file_path);
Jonathan de M.
  • 9,721
  • 8
  • 47
  • 72