moodle 2.1 draftfile.php

moodle 2.1 draftfile.php

by Stephen Catton -
Number of replies: 8

we are experiencing issues with a number of our moodles, where initial icons/pictures are being uploaded and then the icons disappear but the initial file missing icon appear in place of the icon. on investigation the icons url has a draftfile.php inside the details.

this seems to be trying to move the icons to another area but not renaming the url.

this is causing us a big error.

Average of ratings: -
In reply to Stephen Catton

Re: moodle 2.1 draftfile.php

by Ian Miller -

i’m having exactly the same problem. is this a bug?

 

it’s pretty strange. some files work fine, some ‘dissapear’.

 

edit: there’s another thread and a tracker for that

thread: http://moodle.org/mod/forum/discuss.php?d=170655#p821296

tracker: http://tracker.moodle.org/browse/MDL-26782

 

 

In reply to Ian Miller

Re: moodle 2.1 draftfile.php

by Astrid Davine -

A colleague is having a similar issue, with adding a 'Page'.

Within the HTML 'Page' there are icons and links to audio/narrated lecture notes/pdf files.

When hovering over and clicking on the links (in a saved page) I can see they are a 'plugin.php' type link, but when we go into the HTML source of this page, they are 'draftfile.php' type links.  This means the source cannot be used as a template for other pages by simply coping and pasting into another page.  As soon as the HTML source is copied into another page, the links become 'brokenfile.php'.

I understand that the 'plugin.php' links are the ones we need to use - but how do we access them correctly, as they never exist in the HTML source?

Actually, something that might help us in this situation, is knowing how moodle numbers files added.  I can see the files I need in the 'Server files' but don't know how to reference them properly.

Any advice (so that pages don't have to be created manually each time, but rather can be easily copied via the HTML source)?

PS. Our organisation is using Moodle 2.0.

In reply to Astrid Davine

Re: moodle 2.1 draftfile.php

by Stefan Nychka -

Hi.  Use a Legacy Course Files area, or use the duplicate icon, or create a File or Folder and link to that module.

  • Duplicate's in 2.1 (your subj.) but not 2.0 (your P.S.)
  • Be careful about linking to a file within a File or Folder.
    In older versions, they at least broke across a backup/restore.

There probably is a rhyme-and-reason for how the URLs when editing are generated, and how they correspond to actual URLs, the ones you see when not editing, but I don't know it, and it may be fairly complex.  They're meant, as far as I can tell, to be local to that file, when you link and upload while editing via the File Picker.

Cheers

In reply to Stefan Nychka

Re: moodle 2.1 draftfile.php

by Pesh Kap -

hi, I've been fighting this problem for a while now.

after some serious digging, I realized that the filepicker wasn't returning the full url, only the relative one.

So I made this change to filelib.php approximately line 752, begining of function "file_rewrite_urls_to_pluginfile", you'll see  $wwwroot = $CFG->wwwroot;

I changed it to

    $wwwroot = parse_url($CFG->wwwroot,PHP_URL_PATH);
    $text = str_ireplace("$CFG->wwwroot", "$wwwroot", $text);

And now the function and my images/files show up as they should.

Let me know if this helped any of you out, or if there is a better way to achieve what my fix did!

-Pesh

Average of ratings: Useful (5)
In reply to Pesh Kap

Re: moodle 2.1 draftfile.php

by Wolfgang Stettler -

Hi Pesh

We had this problem too on Moodle 2.2. The fix did work, thank you. Is there a tracker-issue for this problem so it will be solved in future releases?

Regards,

Wolf

In reply to Pesh Kap

Re: moodle 2.1 draftfile.php

by Humberto Saback -

Same problem, after I applied the "fix" it fix the path but duplicated the URL, example

site:
www . a . com (without the spaces)

Before the patch:
https://www . a . com/draftfile.php/241/user/draft/image.jpg

After the patch: https://www . a . comhttps//www . a . com/pluginfile.php/352/course/summary/image.jpg

Any idea?
Thanks

.