Get full url to uploaded file in data folder

Is it possible to get full url/path to uploaded file in data folder?

I tried several codes but none return the correct url.

$file_url = elgg_get_site_url() . "file/download/{$vars['file_guid']}";

$file_url = $file->getURL();

Any help is greatly appreciated.

Thanks.

  • rjcalifornia,

    I'm simply using embed code to play the movie, here is the complete code partially taken from zaudio:

    $file = get_entity($vars['file_guid']);
    $file_url = elgg_get_site_url() . "file/download/{$vars['file_guid']}";

    (also tried "action/file/download?file_guid=..." with same results)

    <embed src="<?php echo $file_url;?>" Pluginspage="http://www.apple.com/quicktime/" width="320" height="250" CONTROLLER="true" LOOP="false" AUTOPLAY="false" name="IBM Video"></embed>

    Now if I replace "embed src="<?php echo $file_url;?>"" with url to file I uploaded via FTP to root folder (embed src="http://mysite.com/moviename.mov/ ) than it works.

    I'm stuck now, not sure what else to try :(

    would it be possible to create a special view that would render file from data folder into a link?

    Thanks everyone for great support.

  • Hmm... Ok where are you placing this code? On the file page?

    I think for accomplish what you want you should read this:

    http://docs.elgg.org/wiki/Plugins/File_repository

    (Note for developers at the bottom of the page)

    I mean you should extend it, rather than editing the files plugin directly.

    Or you could try this to get the file URL:

    $download_url = elgg_get_site_url() . "mod/file/download.php?file_guid={$vars['entity']->getGUID()}";

    Rodolfo Hernandez
    Arvixe/Elgg Community Liaison

  • As RJC just wrote -- that shud do it.

     

  • rjcalifornia, yes I will be extending it through plugin or theme, I'm just testing now to see if I can even get it to work :)

    I tried your url suggestion but still nothing, it displays and works as a link to download file but it does not load the file in the player.

    I've tried flowplayer and video.js and for those,  "mod/file/download.php?file_guid=" type of url seem to be working fine and loads file in player fine but obviously not for the quicktime player embed code. Could it be because other two players use javascript to embed file in the player?

    I don't know what else I could try, maybe it's not possible.

    Thanks everyone for the help. I will be still playing with it so if anyone has any more suggestions, please post it.

  • @Nooby: that code looks correct - maybe not woiky b/c of some other issues or maybe just code entered sightly incorrectly @ there..

    Post your *full code* somewhere for download - so we can test better on our xampp...

     

     

     

  • @Nooby Yes, post the code or at least tell us what are you editing. That would be helpful

    Rodolfo Hernandez
    Arvixe/Elgg Community Liaison

  • I wonder if the player is parsing the URL looking for a .mov file extension or something...

  • Matt, I think you are right, it has to be the way player parses the url, when I was trying other players, some will load files and some would not using elgg download link as url. But every time I upload file via FTP to domain root and call the movie file in "http://mysite.com/moviename.mov/" format, than IT WORKS :(

    rj and Dhrup , my setup is simple just overriding some file views. I copied structure from zaudio and nubesoplayer, right now I'm just testing for .mov files. I already posted main code above but here it is again.

    created plugin with structure: views/default/file/specialcontent/video/default.php

    default.php  contents:

    echo elgg_view('my_plugin_name/player', array('file_guid' => $vars['entity']->getGUID()));

    views/default/my_plugin_name/player.php  contents:

    $file = get_entity($vars['file_guid']);
    $file_url = elgg_get_site_url() . "file/download/{$vars['file_guid']}";

    (also tried "action/file/download?file_guid=..." with same results)

    <embed src="<?php echo $file_url;?>" Pluginspage="http://www.apple.com/quicktime/" width="320" height="250" CONTROLLER="true" LOOP="false" AUTOPLAY="false" name="IBM Video"></embed>

    That's all this plugin has.

    Here is the list of codes I tried to get the url but none works, only uploading file via FTP to domain root and calling the movie file via "http://mysite.com/moviename.mov/" format works.

    //$file_url = $file->originalfilename;
    //$file_url = $file->getFilenameOnFilestore();
    //$file_url = $file->FilePluginFile();

    //$file_url = elgg_get_site_url() . "file/download/{$vars['file_guid']}";
    //$file_url = elgg_get_site_url() . "action/file/download?file_guid={$vars['file_guid']}";
    //$file_url = $entity->getURL();
    //$file_url = $file->grabFile();
    //$file_url = get_entity($file);

  • ¡AY!

    (1) " Post your "full code* somewhere for download - so we can test better on our xampp... "

    ()2) @Nooby Yes, post the code or at least tell us what are you editing. That would be helpful

    ---> && That's 2x yew's got asked ;-P

    +NB: 'would e helpful" in #2 (RJC) kinda means to you ;-) not us ;-oO 

    Snippets won't do quite as well -- because => needs to see the whole picture.. && mebbe can test @xampp ! seems u r turning down offers from 2 of the best-est @ ELgg ;-( LOLZIES ;-P

     

     

  • Hi,

    You don't need to do all that stuff since you are using nubeso plugin. Edit that plugin to do what you need (play mov files). Just add the MIME type for .mov and then use the code there.

    Rodolfo Hernandez
    Arvixe/Elgg Community Liaison

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking