Solved

How do get the filename string?

Posted on 2011-03-20
2
266 Views
Last Modified: 2012-05-11
Hey Guys, how can I get the string of the filename from the following:

$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];

Open in new window


When I hardcode the the filename my exec () function works perfectly but $filename doesn't appear to be a string?

exec('convert /var/www/valums/server/uploads/files/MIPS.pdf[0] /var/www/valums/server/uploads/preview/' . $filename . '.jpg');

Open in new window


Thanks in advance.
0
Comment
Question by:the_con
  • 2
2 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 35177273
Use var_dump() to print out the contents of $filename.   You will be able to see the data type.  If you need to cast it as a string, you might do something like this:

$pathinfo = pathinfo($this->file->getName());
$filename = (string)$pathinfo['filename'];
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 35183258
Thanks for the points - it's a great question, ~Ray
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now