1

I need some help. I have developed a software for images, at the end of this software it offers you the option to print pictures. So I move the pictures into a folder onto their desktop. I would like to add a button to open that folder for browsing once the transfer has been complete. Here is my code for transferring the images. I have no idea how to open a folder though. Just like when you are browsing a folder for file upload. That is how I want it to look. Any help would be greatly appreciated!!!

PHP

<?php
if(isset($_POST['yesplease'])){
          $img = $_POST['print'];
          $path = $_POST['path'];
          $f = $_POST['f'];
          $h = $_POST['h'];
          $gp = $_POST['gp'];

            $FolderDate = $_POST['f'];
            $FolderName = $_POST['gp'];
            $hour = $_POST['h'];

        // Desired folder structure
        $structure = './print/'.$FolderDate.'/'.$hour.'/'.$FolderName;

        // To create the nested structure, the $recursive parameter 
        // to mkdir() must be specified.

        if (!mkdir($structure, 0, true)) {
         die('Failed to create folders...');
        }
          foreach ($_POST['print'] as $key => $value) {
              echo " ".$value.",";
                $file = $path.$value;
                $newfile = $structure.$value;

                if (!copy($file, $newfile)) {
                    echo "failed to copy $file...\n";
                }
              }
          }  
      ?>

I AM USING WAMP... I AM NOT ACTUALLY ON A SERVER ONLINE. Thanks!

alain.janinm
  • 19,951
  • 10
  • 65
  • 112
luv2code
  • 1,216
  • 6
  • 22
  • 42
  • The pictures are uploaded from client(browser) to server? Where do you want to open a folder? – tonymarschall Mar 06 '12 at 15:12
  • By 'desktop', are you talking about their folder on your server? Or their own computer? How is this storing the pictures onto their computer? – Luke Shaheen Mar 06 '12 at 15:15
  • 1
    It is a project I am working on with Wamp... it is a simple offline application using their folders. So nothing is actually on a server. It is all in a wamp folder on their computer. – luv2code Mar 06 '12 at 15:16

3 Answers3

2

You can't do this.

The majority of browsers (such as FireFox and Opera) prohibit scripts opening up file dialogs because it's a real security risk...

Community
  • 1
  • 1
hohner
  • 11,498
  • 8
  • 49
  • 84
2

How about something like this?

<form>
  <input type="button" value="New Window!" onClick="window.open('/location/to/whatever/you/call/their/desktop','theirdesktop','width=400,height=200')">
</form>
Ryan Kempt
  • 4,200
  • 6
  • 30
  • 41
  • If the OP wants the script to access the visitor's _local_ files this will not work – hohner Mar 06 '12 at 15:19
  • Thanks for this, but I am looking to actually open a folder on their computer. I am using Wamp... so it is not on a server. – luv2code Mar 06 '12 at 15:22
  • Ok how about you write a small batch file or VBScript and place it in the temporary folder, then when the user clicks OK to view the files on their desktop, it prompts for the download / opening of the VBScript or batch file or w/e that opens a Windows Explorer window to that location... then click Run and presto! You could even edit the VBScript or batch file with PHP for each user if the locations are different on the fly. lol – Ryan Kempt Mar 06 '12 at 15:25
  • could you give me an example? – luv2code Mar 06 '12 at 15:45
  • Create a new file called on your web server called openFolder.bat and you can write the contents of the file with PHP before prompting the user if you'd like or if all of the locations are the same just statically set it... and link to this file when they click open folder / view my pictures on desktop. They click the link and are prompted with the download of openFolder.bat - they need to click run, and that's about it. The contents of the openFolder.bat file should look something like this: %SystemRoot%\explorer.exe "C:\Picture\Folder" – Ryan Kempt Mar 06 '12 at 15:50
0

This can only work when you run this script locally, in Wamp or Xamp

PHP can't browse folders of the client's computer.

MakuraYami
  • 3,398
  • 3
  • 16
  • 19
  • that is what I am using.. wamp! Please help me. :( – luv2code Mar 06 '12 at 15:21
  • In that case lets say your wamp folder is on C:/wamp/www/urscript.php and desktop is on C:/Users/urUser/Desktop/folder/ the link would be "../../Users/urUser/Desktop/folder/". – MakuraYami Mar 07 '12 at 10:08