Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2010
    Location
    Chicago, Illinois
    Posts
    22
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Launch External App from PHP with a Mac

    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:

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

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

    Elizabeth

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    You need to issue headers with the content-type set for the client machine to be able to decide which programme to use.

    http://uk.php.net/manual/en/function.header.php

  • #3
    New Coder
    Join Date
    Mar 2010
    Location
    Chicago, Illinois
    Posts
    22
    Thanks
    6
    Thanked 0 Times in 0 Posts
    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).

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    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:

    http://www.iana.org/assignments/media-types/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •