Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2013, 02:03 PM   PM User | #1
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
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?
sorlaker is offline   Reply With Quote
Old 01-03-2013, 03:30 PM   PM User | #2
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,502
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
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.
__________________
ZCE
kbluhm is offline   Reply With Quote
Old 01-03-2013, 07:14 PM   PM User | #3
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
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.
sorlaker is offline   Reply With Quote
Old 01-03-2013, 07:44 PM   PM User | #4
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,502
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
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:
__________________
ZCE
kbluhm is offline   Reply With Quote
Old 01-03-2013, 08:04 PM   PM User | #5
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
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
sorlaker is offline   Reply With Quote
Old 01-04-2013, 12:45 AM   PM User | #6
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
Quote:
Originally Posted by sorlaker View Post
Still can't drag it
What do you want to do?
tempz is offline   Reply With Quote
Old 01-04-2013, 12:59 AM   PM User | #7
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
Quote:
Originally Posted by tempz View Post
What do you want to do?
I wanna drag the link to my kmplayer.
sorlaker is offline   Reply With Quote
Old 01-04-2013, 01:01 AM   PM User | #8
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
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
tempz is offline   Reply With Quote
Old 01-04-2013, 03:12 AM   PM User | #9
sorlaker
Regular Coder

 
Join Date: Dec 2009
Posts: 166
Thanks: 23
Thanked 1 Time in 1 Post
sorlaker has a little shameless behaviour in the past
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.
sorlaker is offline   Reply With Quote
Old 01-04-2013, 04:30 AM   PM User | #10
tempz
Regular Coder

 
Join Date: Jul 2012
Location: London
Posts: 436
Thanks: 4
Thanked 80 Times in 80 Posts
tempz is an unknown quantity at this point
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..
tempz is offline   Reply With Quote
Old 01-04-2013, 06:03 AM   PM User | #11
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:02 PM.


Advertisement
Log in to turn off these ads.