[contentbox] Adding a PDF link to a page

Sorry for all the dumb questions tonight guys but this is my first cb app :slight_smile:

In a page I want to include a link to a PDF for the user to download. I create some text “Click here to download”, highlight the text and select link from the toolbar. I browse the server and select my pdf and save the page. When I go to the front end and click the download link I get taken to 404: requested path not found and this is the link its taking me to.

http://toysforshots.dev/__media/DonationRequestLetter_Toys%20for%20Shots_2013.pdf

Any idea whats going on?

Dan,

I fell victim to this the other week, the key is to make the changes to the rewrite rules

Media Types

RewriteCond %{REQUEST_URI} /__media/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]

Needs to be added to the rules.

This seems to be in the rewrite rules already.

Media Types

RewriteCond %{REQUEST_URI} /__media/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]

#Images, css, javascript and docs, add your own extensions if needed.
RewriteCond %{REQUEST_URI} .(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
RewriteRule ^(.*)$ - [NC,L]

#The ColdBox index.cfm/{path_info} rules.
RewriteRule ^$ index.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]

Ok, then the next step is your routes file

setValidExtensions(‘xml,json,jsont,rss,html,htm,cfm,print,pdf,doc’);

Was changed awhile ago as well, try that.

Yep… that is there as well

// The valid extensions this interceptor will detect
setValidExtensions(‘xml,json,jsont,rss,html,htm,cfm,print,pdf,doc’);

Hmm, seems strange then.

Dan, I had a bit of a play with it some more. Can you confirm that the file is in the root of your content files.

Yes… the file is in

/modules/contentbox/content/

Just out of curiosity, what happens if you replace __media with that and try to access it via the URL?

http://toysforshots.dev/modules/contentbox/content/DonationRequestLetter_2013.pdf

The pdf is rendered in the browser

That is different to what you orginaly posted, do you have spaces or %20 in the name or none?

Ya I deleted the original one and removed the spaces from the file name and tested it again.

Which means __media should work now, I think the problem is that the file name was with spaces and the url should be entered without spaces. In other words the url should be first called like

http://toysforshots.dev/__media/DonationRequestLetter_Toys for Shots_2013.pdf

I am sure I ran into this awhile ago.

This is the path to the file on disk

/modules/contentbox/content/DonationRequestLetter_2013.pdf

When I drop it on the page it produces

http://toysforshots.dev/__media/DonationRequestLetter_2013.pdf

404: Requested path not found.

It has to be something with the rewrite, ill keep digging tomorrow. Thanks for all of your help Andy!

Dan, one more thing… Can you confirm that the settings haven’t changed in the dashboard? The media folder can be controlled in here, just one more thing to check.

I am wondering if __media is either not translating to the ContentBox setting, or it is translating to another area altogether?

Under settings > media manager > directory root

/contentbox/content

This has to be something with PDF type. I can view an image directly in the browser and inserting images in the content editor works just fine.

http://toysforshots.dev/__media/tft_logo.jpg

I just tried dropping a png file in a folder called blog in my content folder and I am having the same problem.

http://toysforshots.dev/__media/blog/tfs_facebookpage.png

404 requested path not found.

does the directory blog exist in the media content folder?

yep… I created it through the media manager.