View Full Version : Launch External App from PHP with a Mac

11-18-2010, 01:09 AM
I want be able to press a button on my PHP page, have Photoshop launch and open the filename specified in my PHP form data. I have been looking for hours for a solution that is supposed to work, but none do. The PHP file is only going to be viewed on my local machine, by me, so there is no likelihood of abuse.

I am using a Mac with OSX 10.6.5 so possibly this is complicating the issue.

I've tried shell_exec, fopen, and exec() just to get Photoshop to launch, and none seem to work. Here are some examples of what I have tried:

?>(where "Untitled2.app" was an Automator script that launches Photoshop, placed in the same directory with my PHP page)

exec("file:///Macintosh HD/Applications/Adobe Photoshop CS5/Samples/Adobe Photoshop CS5.app");
?>Is this just not possible to do? TIA for any help! :)


11-18-2010, 01:26 AM
You need to issue headers with the content-type set for the client machine to be able to decide which programme to use.


11-18-2010, 02:54 AM
Thanks for your help. I may be misunderstanding but here is what I'm getting when I try all conceivable options...

If I set the header location as the image, and set the content-type as an image type or "application/photoshop," the image just displays in the browser.

If I set the header location as "photoshop" and the content as "application/photoshop," the browser tries to save Photoshop as a binary file.

If I set the content type as "application/pdf" and use exec(Photoshop application), Firefox tries to save the PHP page (as a PHP page, not an image file).

If I set the content type as "image/jpg" and use exec(Photoshop application), Firefox displays a blank page with the Photoshop path displayed in text (there is no page source).

11-18-2010, 03:15 AM
There's no such mimetype as application/photoshop as far as I recall. You have to serve the file with an official mimetype. How the client then deals with it depends on which programme is set as the handler for each specific filetype.

Have a look through the IANA lists: