Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can files such as PDFs be uploaded to custom URLs? I would like to upload a PDF to www.example.com/whitepapers/pdf.pdf instead of www.example.com/wp-uploads/....

I found a plugin called WP Easy Uploader which seems OK, but I wanted to check if there are any other solutions.

One solution I was contemplating is to have the PDF treated as a page so I can assign a parent page to the PDF. This will handle any redirects in case the URL of the parent page is changed.

UPDATE - Not Considering WP Easy Uploader any more since I don't want to have any FTP access from within a Wordpress installation for security reasons.

share|improve this question
add comment

3 Answers

UPDATE: Found Media Library Categories which sorts media by custom categories. All I need now is for a similar plugin to add that category to the URL so I can perform URL rewrites and get what I need!


Found a couple of plugins.

Relocate Upload allows you to upload to any folder and then have a drop down list when uploading media to place that new media in your custom locations. It looks ok but the files are placed in actual physical folders. It would be better if it could upload anything in one content folder and the 'folder' used in the link would be just a permalink. Also it did not work well on a quick localhost installation. It kept trying to access C:\wamp\www... instead of http://localhost/

Custom Upload Dir allows you to upload in custom directories but this did not meet my requirements.

About WP Easy Upload - I do not want to use it since I don't want to give FTP access to any plugin inside the installation for security reasons.

share|improve this answer
add comment

Attachments in general (images, but also files like PDFs) have a special "attachment page" of the form example.com/main-post/attachment/file-title/. In most themes this is used to display a larger version of the image, still in the theme layout (so it returns a HTML file with the image in it, not the image directly).

You could exploit this by creating a template file that does serve the file directly, instead of just displaying it. Then if you create a page example.com/whitepapers/ with an attachment called file.php, the URL of the file will be example.com/whitepapers/attachment/file.

You would need to create a file in your theme directory called either attachment.php (if you want to do this for all attachments) or application.php (if you only want to do this for files with a mime type like application/*). In that file you get the attachment file location and then readfile() it to the browser. I guess there are already plugins out there that can do this for you.

share|improve this answer
    
will give this some thought and try some things out. Thanks for the tip –  Matthew Xerri Jun 2 '11 at 7:41
    
I was thinking about this again and I have 2 questions: 1) If I attach a Whitepapers file to a different page, then I have 2 URLs for the same file which is not so SEO friendly 2)The file itself would not have a URL but just a URL depending on if it is attached or not. Right? –  Matthew Xerri Jun 3 '11 at 5:24
    
@thearchitect: If you link to the same file from a different page, it will have the same URL (like when you use the same image in two different pages). If the file has not been attached to a post it will still have a (generic) URL, but I would have to look up what it was then. You could change the attachment URL so they all appear as /media/ if you want. –  Jan Fabry Jun 3 '11 at 8:22
    
@Jan Does your solution require me to create an empty page for each media file? Also I can't specify different paths for different media categories like this. Here is the scenario I would like. I want to upload a PDF, set a category to that PDF (which is irelevant to the post/page it is attached to) and have a URL created to that PDF like example.com/CATEGORY/FILENAME.pdf –  Matthew Xerri Jun 3 '11 at 8:34
    
@thearchitect: That should be possible with some advanced rewrite rules (read: not with the "core" code from WordPress). Let me think about it and I'll try to come back with an answer. –  Jan Fabry Jun 3 '11 at 8:38
show 3 more comments

Solution #1 You can change your Media Path. Go to Settings->Media Change default "wp-content/uploads" to "whitepapers" of course if you upload other than whitepapers, this solution won't work so well.

Solution #2 Use Pretty Link to customize your path I have been using Pretty Links since I've been using WordPress; a few years now.

Mostly to simplify paths to files.

You can map "abc.com/whitepaper/file.pdf" into "abc.com/wp-content/uploads/file.pdf"

http://blairwilliams.com/pretty-link/

share|improve this answer
    
thanks for the tip. I'm guessing that with this plugin, I would need to create a pretty URL after each upload right? –  Matthew Xerri Jun 2 '11 at 7:40
    
@thearchitect - yes, this is a plugin, you would need to create a URL for each upload. The nice thing is you can map any Pretty URL into any URL to your site or an external site. ie. mrwes.net/linkedin –  mrwes Jun 2 '11 at 13:43
    
I think the plugin creates too much of an overhead since it runs javascript, tracking, etc. We already have most of its functionality in place. We just need something to better organize uploads –  Matthew Xerri Jun 3 '11 at 5:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.