Uploading and linking files without the GUI editor

Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Number of replies: 12
Picture of Particularly helpful Moodlers Picture of Translators
Hi all

I have uploaded and linked a series of files in the top section of a course. I found it odd that the links are like . I am not sure how the "draftfile" came in, my guess is that, since I do not have a GUI editor active in profile, I must have uploaded the files to a folder resource and got the URL copied. Anyway, it worked.

Now, after a couple of weeks all the pictures are broken. Now the src of such img are like .

What could have happened?

Is this workflow not supported any more?

Moodle version 2.6. I don't have admin access to this particular Moodle. I don't like the idea of trying to reproduce it in an own Moodle, because I can not wait indefinitely until the images break!
Average of ratings: -
In reply to Visvanath Ratnaweera

Re: Uploading and linking files without the GUI editor

by Guillermo Madero -

Hello Visvanath,

The images posted are broken.

Very little info here. Have you checked with the admin(s) to see if (s)he/they changed something? You know, they would need to start checking the Moodle and web server logs, enable debugging, etc.

In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
This is going out of control. I'm pretty sure I had two URLs in my OP:
- was the original which worked a couple of weeks (dots while I don't have the original anymore).

- is the broken one now.

Edit: The forum suddenly purging the URLs from the message! A screen shot of my post is attached below.
Attachment exampleurls.png
In reply to Visvanath Ratnaweera

Re: Uploading and linking files without the GUI editor

by Guillermo Madero -

Hello Visvanath,

Are you referencing images at http://moodle.example.com/ ? thoughtful I'm getting lost. I only see "broken image" icons.

In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Guillermno

No. I am just annonymizing the links without disclosing the real name of the site, as formulated in RFC 2646. I have changed the references to the pics by changing the real domain to moodle.example.com. Of course I don't expect those "images" to appear in my posts, because they don't exist!

My point was that in a site pics had references with draftfile.php in them. Then after some time they broke.
In reply to Visvanath Ratnaweera

Re: Uploading and linking files without the GUI editor

by Guillermo Madero -

Hi Visvanath,

I kind of gathered much about the anonimizing part but then I wondered about the images I thought you wanted to show. So it was about the URL and not about the image, OK.

I still don't get a clear picture of the process as you described it in the opening post, but since you mention the "draftfile" part of the URL I'll start with that, at the risk of saying something already known to you.

When one first creates a resource and uploads an image, that image is saved in a temporary area that Moodle references with the draftfile.php script, like so:

draftfile.php/5/user/draft/143851244/myimage.png

Once the resource is saved, the file is moved to a final area, which Moodle now references with the pluginfile.php script, for example:

pluginfile.php/33/mod_page/content/1/myimage.png

When one returns to edit the resource, Moodle once more moves the file to a temporary area and so we get a new temporary URL:

draftfile.php/5/user/draft/633419734/myimage.png

If the edition is cancelled, nothing happens and the image at the original final area remains there, but if the edition is saved (even if we didn't actually edit anything), then the image is saved to a new final area:

pluginfile.php/33/mod_page/content/3/myimage.png


So, copying these temporary URL and pasting them in another resource or activity will actually cause problems because Moodle now looses track of the file and that's when we get a broken path.

Let's assume that I have a page with an image, I open that page in edit mode and copy the URL of the image, for example:

draftfile.php/5/user/draft/506189592/myimage.png

Now, I cancel this edition and then I go to create a new resource in which I paste the copied URL. Since Moodle had already created a temporary reference path for this particular new edtion, for example:

draftfile.php/5/user/draft/398686834

the reference carried along with the previously copied and pasted URL is actually useless (because it is a temporary number or reference created for a particular editing instance), and so, when the resource is saved Moodle would have expected to have something at the 398686834 path and not at the copied 506189592 one. We now have a broken reference which Moodle references with the brokenfile.php script, like this:

brokenfile.php#/5/user/draft/398686834/myimage.png


I hope this description will help you determine the root of the problem.

 

--- edited

This is why at the following post I adviced using the file picker (the recent files option) and not copying the code:

https://moodle.org/mod/forum/discuss.php?d=224907#p1100882

Average of ratings: Useful (5)
In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Guillermo

Many thanks for your detailed explanation. So, in short, I have used a URL "in transition? No, after years still I can not come to terms with the repository concept of Moodle 2. I fear, I have no alternative.

===
`I'm afraid I can't put it more clearly,' Alice replied very politely, `for I can't understand it myself to begin with; and being so many different sizes in a day is very confusing.'

`It isn't,' said the Caterpillar.

`Well, perhaps you haven't found it so yet,' said Alice; `but when you have to turn into a chrysalis--you will some day, you know--and then after that into a butterfly, I should think you'll feel it a little queer, won't you?'

`Not a bit,' said the Caterpillar.

`Well, perhaps your feelings may be different,' said Alice; `all I know is, it would feel very queer to me.'

`You!' said the Caterpillar contemptuously. `Who are you?'
In reply to Visvanath Ratnaweera

Re: Uploading and linking files without the GUI editor

by Guillermo Madero -
So, in short, I have used a URL "in transition?

Basically, yes.

Cheshire cat smiling

In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
alice24a.gif

`Well! I've often seen a cat without a grin,' thought Alice; `but a grin without a cat! It's the most curious thing I ever saw in my life!'

Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
This is the explanation to what was happening:

My earlier work flow was "wrong" according to Moodle. This is what I was doing:
- upload the images to a Folder resource first
- whenever I need an image, visit the Folder, get the link to the image I need
- paste it to the <img> tag in HTML

That confuses Moodle. This is what it expects:
- the first time I need an image upload it in the GUI editor
- whenever I need it again, select it in the File picker (again GUI)

Painful for me (because I do not use the GUI editor). But that is how it is.
Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Uploading and linking files without the GUI editor

by Leticia Dark-rose -

Hi Guillermo,

I was wondering if you have experienced the random loss of images in Moodle that have been placed using the file picker. We are using 2.2.8 and i have started noticing image links breaking. There is no method to them, they range from course container images to profile pictures, quiz images and even videos.

Do you have any information so i may investigate further.

Many Thanks

Leticia

In reply to Leticia Dark-rose

Re: Uploading and linking files without the GUI editor

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Leticia

Guillermo has left this forum sometime back. May be it is a good idea to ask the moderator to split your discussion from the main thread and to add more details about your problem to the new thread.