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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

    Link to file in local pc

    How should i make this work ?

    PHP Code:
    echo "<a href=\"file://c://filePath/$file\">$file</a>"
    is it possible?

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    It's certainly possible, but the only person that will be able to view it is you and anyone else that happens to have a file with that path and name on their local PC... only they'll view their own file, not yours.

    So what you're looking to accomplish... isn't accomplishable in the way you're probably looking for. You'll have to upload it to a remote server where everyone will have access, then link to that path.

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    No that's exactly the thing i wanna do. Filtering files from my own folder. Then i wanted to make them "dragable" to a video player program.

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Ah, well alright then:
    PHP Code:
    echo "<a href=\"file:///C:/filePath/$file\">$file</a>"
    Note the triple slash after file: and single slash after C:

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Quote Originally Posted by kbluhm View Post
    Ah, well alright then:
    PHP Code:
    echo "<a href=\"file:///C:/filePath/$file\">$file</a>"
    Note the triple slash after file: and single slash after C:
    Still can't drag it

  • #6
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Quote Originally Posted by sorlaker View Post
    Still can't drag it
    What do you want to do?

  • #7
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Quote Originally Posted by tempz View Post
    What do you want to do?
    I wanna drag the link to my kmplayer.

  • #8
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Quote Originally Posted by sorlaker View Post
    I wanna drag the link to my kmplayer.
    I see! I don't know what your kmplayer is but it seems like you want to drag a file from your local computer to your browser and make it play? or you want to drag a file from your local computer and set a upload script which then plays the song via a custom player? or am I not even close to what you want

  • #9
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Quote Originally Posted by tempz View Post
    I see! I don't know what your kmplayer is but it seems like you want to drag a file from your local computer to your browser and make it play? or you want to drag a file from your local computer and set a upload script which then plays the song via a custom player? or am I not even close to what you want
    No i'll show the php script. So that it's gonna be easier to understand what i'm trying to do.

    PHP Code:
    <?php
        $dir 
    "C:/Users/User/Downloads/";
        if (
    $handle opendir($dir)){
            while((
    $file readdir($handle)) !== false){
                if (
    preg_match("/(.*)To(.*)Love[ -]Ru(.*)[.](avi|mp4|mkv)$/i"$file)) {
                    echo 
    "<a href='file:///".$dir.rawurlencode($file)."'>$file</a>";
                    echo 
    "<br>";
                }
            }
        }else{
            echo 
    "cannot";
        }
    ?>
    Then i wanna drag the link to my kmplayer. One interesting thing is that i can drag the file and play through Chrome's Ctrl+J to my kmplayer but not from my webpage.

  • #10
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Getting error: Parse error: syntax error, unexpected '.' on line 4

    line:
    PHP Code:
    if (preg_match("/(.*)To(.*)Love[ -]Ru(.*)[.](avi|mp4|mkv)$/i"$file)) { 
    - Fixed that.

    Now: Parse error: syntax error, unexpected T_STRING on line 5

    PHP Code:
    echo "<a href='file:///".$dir.rawurlencode($file)."'>$file</a>"
    Last edited by tempz; 01-04-2013 at 04:39 AM.

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Drag and drop is beyond the capabilities of a server side language regardless of if its on a local machine or not. The behaviour you are describing is a client functionality, not unlike the use of dragging an image onto your filesystem from a browser.
    There is nothing you can do to force a drag and drop functionality using a server side language.


  •  

    Posting Permissions

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