Skip to content


Add From Server

WordPress.org(and Download): http://wordpress.org/extend/plugins/add-from-server/
Bug Reports: Please direct all bug reportsvia my contact page: http://dd32.id.au/contact-me/

I took the challenge: http://foolswisdom.com/media-library-and-wordpress-plugin-challenge/

WordPress 2.5 includes a new Media manager, However, It only knows about files which have been uploaded via the WordPress interface, Not files which have been uploaded via other means(eg, FTP).

So i present, “Add From Server” a WordPress plugin which allows you to browse the filesystem on the webserver and copy any files into the WordPress uploads system, Once “imported” it’ll be treated as any other uploaded file, and you can access it via the Media Library.

Changelog

1.0

  • Initial Release

1.1

  • Bug fix, Please note, An important bug has been fixed in this release, Any files previously added, and subsequently deleted will delete the file which was imported, the copy remains in the uploads folder however.

1.2

  • Fixed filename oddness including old directory names
  • Added a check to see if the file exists in the Media library allready
  • Added a check to see if the file is allready in the uploads folder before importing, and if so, simply add it to the database, do not mash the filesystem

1.3

  • French Translation
  • Spanish Translation
  • Select All
  • Import files and do not attach to any specific post (Causes it to not appear in the gallery)

1.3.1

  • Javascript Typo

76 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. sourena says

    Hi,
    I have translated your .mo file into Persian. Let me know if you are interested in adding it to the package.

  2. max says

    hi !

    thanks for your work !!
    i added your plugin (to wordpress 2.6) but it says the files are copied, but in fact there not.
    all necessary rights are set on folders. the names of my copied images appear in the media library but without any picture. when inserting it into article, there no picture either.

    do you have any clue ?

    thanks a lot !

    max

    • DD32 says

      It could be a known bug thats affecting you, Which i believe is fixed in the 2.0 release, The 2.0 release however currently requires WordPress 2.7+

      Can you check the /uploads/2008/11/ folder, And see if the images are copied there, And that the thumbnails have been created?

      • max says

        thanks for your quick answer !
        yes i’ve checked that no pictures are created under uploads/2008/11…. :(
        i didn’t know wordpress was available in 2.7 version, is it ?
        so you advice me to wait for the next version ? :)

        thank you

        • max says

          i am afraid i have to confirm that it doesn’t work with wordpress 2.7 beta2…….
          what a pity!
          thanks the same!!!

  3. Daniel says

    Hi there, I recently moved an old Blogger blog over to Wordpress. I have lots of images that I realise weren’t copied over using the built in Wordpress function. I had manually copied them all to the uploads folder, and sorted them into more folders by date (e.g. uploads/2005/10 etc) to match the Wordpress method. They weren’t showing up in my Media Library until I found your fantastic plugin.

    I’ve just tested it on the first batch of images and like you said it doesn’t copy images already there but takes the file’s url as the date so I have items in the media library for each month (not too worried about individual days atm but I’ve yet to look at your other plugin “dpost-uploads”.

    There’s a problem, however: It seems to have taken the full url from the server for the image, so rather than -

    http://mywebsite.co.uk/blog/wp-content/uploads/2005/10/image.jpg

    It is using -

    http://mywebsite.co.uk/blog//home/username/public_html/blog/wp-content/uploads/home/username/public_html/blog/wp-content/uploads/2005/10/image.jpg

    The result is that the links in the media library are broken and I assume they will be when I update the posts that use on those images.

    Any help you can give would be appreciated.

    • DD32 says

      That problem appears to be related to certain hosting setups, I hope version 2.0 (WP 2.7+ only) will fix that..

      But as for fixing it in the older version of the plugin, You can try removing line 162: (realpath)
      http://plugins.trac.wordpress.org/browser/add-from-server/tags/1.4/add-from-server.php#L162
      and see if that fixes it, There was a similar problem in core WP’s uploader at one stage

      So change it from:

      foreach($files as $file){
          $file = realpath($file);
          $id = frmsvr_handle_file($file, $gallery);
      

      to:

      foreach($files as $file){
          $id = frmsvr_handle_file($file, $gallery);
      
    • Daniel says

      Hi Dion, thanks for the speedy reply! I’m afraid it didn’t work (assuming I amended it correctly). If this is a quirk of my hosting setup then I’ll guess I’ll live with it, but thanks for your suggestion. I think I’ll just amend the links in my posts now and then to convert them all over to the Wordpress uploads folder, and not worry about being able to see them in the Media Gallery since they’re old posts anyway.

      Still, I will keep one eye on your blog. Thanks again=)

  4. Nicolas says

    Hi !

    Your plugin is great but there is a hudge problem : you can browse the whole file system, even the files that are out of the www directory. This can be a security problem on shared hosting environement.

    I edited add-from-server.php so that you can set an optional root folder in your wp-config.php to prevent users from browsing out of this folder :

    // Root path for Add From Server plugin
    define(‘FRMSVR_ROOT’, dirname(__FILE__).’/wp-content/uploads/’);

    I also removed the “Parent folder” link if the current folder is the root.
    Here is the diff :

    [DD32 Edit: The diff is too large to post, If you'd like to follow up with a link to a diff hosted somewhere, that'd be good, See my comment in reply - also note, It'll be non-compatible with version 2.0 due out in the near future when WP 2.7 is released]

    • DD32 says

      Hi Nicolas,
      I’ve decided against implmenting your suggestions, The Plugin is designed to allow access to the filesystem of the server, If the webhost has insecure permissions (Like many slack shared hosts), Then that is not my problem, Its the hosts problem to give their customers better security/privacy, One of the reasons that mass-deface attacks can take place is because of shared hosts with slack filesystem permissions.

      So in short: I see it as a Hosters security problem, which THEY need to fix, Its not a security issue for the plugin. My plugin does nothing special/out of the ordinary than any other PHP script, so its not like the plugin purposely bypasses hosts security measures.

      • Nicolas says

        The problem is not only the security but if you add a file that is out of your www directory you won’t be able to access it via the browser…

        By the way, my modifications do not affect the way the plugin works since you do not define FRMSVR_ROOT, except for the “parent folder” link at filesystem root.

        Here is my diff for version 1.4 : http://n.bernier.free.fr/divers/add-from-server.php.diff

        • DD32 says

          You should be able to access files that are outside of the www directory, As the file is copied to the WordPress uploads folder upon adding (Unless it allready exists within the WordPress uploads folder).

          I understand that it doesnt affect the functionality of the plugin, and on furthur thought, Ignoring the ’security’ issues, I can see that some users might like to make a certain folder their ‘root’ folder for situations where the path is long(like some shared hosts), I might actually add some functionality along those lines to 2.0, But no promises :)

          • ovidiu says

            this “hack: would be interesting only for wpmu users, I guess, as tehre are a multitude of blogs hosted within one instance of wpmu… but as free blogs rarely come with the ability for FTP upload files, this is of limited use…

  5. ovidiu says

    hi there.
    I gave your 2.0 alpha version whirl, and it works perfectly for me.
    There is only one thing though, if you could add that this would be fabuluos:

    could your plugin also execute all actions/filters that are executed when a file is uploaded through the normal media interface?

    i.e. I have several plugins that do affect uploaded files as resizing them to a certain size, changing their names if spaces, dashes and underscores appear in the filename, etc.

    • DD32 says

      I’ll look into it.

      I’m not too sure of which hooks wouldn’t be firing, If you’ve got examples of plugins which are affected, that’d be greatly appreciated.

      • ovidiu says

        hey, this plugin is not firing: h**p://dev.huiz.net/2008/10/04/plugin-resize-at-upload-english/ at least that’s the only one I can see not working right now. The renaming of the files does work. I am using h**p://pixline.net/wordpress-plugins/upload-plus/en/ for the renaming.

        I tried to destroy my links so my comment doesn’t get caught as spam.

        • DD32 says

          WordPress is smart, it detects you attempting to bypass the comment link-number filter..

          Thanks for the plugin, i’ll look into the hooks it uses and see what i can manage :)

  6. osarusan says

    This plugin is awesome! I just noticed 2.0 was released with WP 2.7. Is there a changelog for 2.0? I’d love to see what’s new.

    Thanks for your hard work!

  7. zmin says

    this plugin saved me from a lotta work
    thanks!

  8. Aaron says

    I really love your plugin… amazing, I had issues to start with but now it seems to be working with the recent update…. ISSUE: When I click import it takes me away from the back-end of Wordpress… with no way back (other than reloading your website). Would be nice to have a link back to the Media tab.

    • DD32 says

      Seems to work perfectly fine for me..

      • DD32 says

        Oh, I think i see what you were referring to.. That’ll be fixed in the next release :) Cheers.

  9. Jeff Ivany says

    I’m having problems with some .flv files I’m trying to add. They don’t appear to get the MIME type set when I use Add From Server. This is causing trouble for the theme I’m using as it is looking for the MIME type to display the attached video.

    I’m not sure if this is something with your plugin or not though. The file I’m trying to upload is larger than the max size allowed on my server. I had FTPd the file to my server and then was hoping to use Add From Server to pull it into WordPress.

    Thanks!

    • Jeff Ivany says

      To follow-up, I setup a test server and I can confirm that when I use the WP upload functionality, the MIME type is set properly (application\octet-stream) for the .flv files but when I use Add From Server, it is blank.

      Any ideas?

      Thanks!

      • DD32 says

        Not a clue, I thought the mimetypes were being handled the same as WP does.. But i’ll look into it tomorrow and get back to you :)

        • DD32 says

          Mime-types are working as expected for me with the latest version of the Plugin.. So not sure why its not working for you, I use the exact same WP function call for getting the mimetype that WordPress uses..

          • Jeff Ivany says

            Interesting. I’ll have to poke it with a stick a little more and see if I can find some sort of an error coming out of Wordpress.

  10. Richh says

    Didn’t work for me, which is a shame! The import worked ok, but the paths it generated to embed the images in my blog were all waaay off. For example if a file was in a folder called /portfolio/images/image1.jpg, the path it ended up trying to find the image at was /uploads/2009/01/image.jpg

    Maybe just a bug with my install?

    • DD32 says

      Quite possibly because you’ve mis-interprated the usage of the plugin.

      The plugin is designed to import files from elsewhere on the server into the WordPress uploads, it copies the file to the uploads folder, it does NOT continue to refer to the old location of the image.

  11. NerdSpawn says

    Greetings Dion,

    Since I’m using WP 2.6.1, I’ve just installed your 1.4 version. When I’m in the Add Media window and try selecting multiple files that I’d like to add, I’m getting the following error:
    Fatal error: Function name must be a string in /vhost/vhost8/g/s/c/my-domain-name/www/wp-content/plugins/add-from-server/add-from-server.php on line 218

    Any suggestions would be greatly appreciated, thanks!

  12. Martin says

    It’s not working for me – I’m running 2.7 and whnever I activate and try to access add from server I get this: “Cannot load add-from-server.”

    • DD32 says

      Are you accessing it from the Plugins page or the Menu?

      Are you running any non-standard WordPress Admin themes? Or any plugins which mess with the menu?

  13. nick says

    tres smart. is there any way to ‘add-from-to-server’ by that I mean move something from server to another dir/folder on the SAME server that IS NOT /wp-content/uploads/MM/ (where MM is month, my current upload configuration).

    I’d like to add-from-server some specific content (mp3s, flvs) to non-calendar folders, like /wp-content/uploads/mp3s/ etc. and have that content accessible via the Media Library. Basically just trying to get away from certain media being in calendar folders. is this possible?

    Brilliant! thanks for this useful plugin.

    (I’m on WP 2.7.1 and PHP 5.2.x and everything is smooooooth)

    • DD32 says

      No, However:

      If you create the /uploads/mp3s/ folder, and manually move the files into that folder, and then import using Add From Server, It’ll add it to the media library, and the files will stay put.

      Add From Server only copies them if the original exists outside of the uploads folder (it cares not for the month folders)

  14. nick says

    Ahhh! Interesting tweak, I like it!

    Have a localhost running and just tested this, works like a charm! Brilliant stuff DD32!

    • nick says

      hi DD32, I’ve ran into something of a snag. On my localhost everything works fine, but on my global site my added-from-server files, which are currently stored in a /covers/ folder in the wp-contents/uploads directory, are showing up in the Media Library blank, as empty JPEGs in my current situation. If I ‘view’ the file the source code shows the following:
      wp-content/uploads/2009/02/image.jpg
      it’s looking for the file in the year-month folders!

      however the plugin did properly create thumbnails of the image in its folder:
      wp-content/uploads/covers/image-150×19.jpg

      but the image isn’t viewing in the Media Library! Very strange. Both my localhost and global are PHP 5.2.5 and WP 2.7.1

      Any advice? On my localhost all is smooth, on global site it’s snagged. I’ve deleted the plugin and gone from scratch, the situation is recreated every time.

      thanks!

      • DD32 says

        Sounds odd… I have to admit, I dont actually use the plugin myself very often, I’ll have to do some testing for you and see if theres any bugs in that code branch..

        • nick says

          thanks DD32, I have a lot of use for this given how I keep files on my server.

          I did just realize a mistake on my part, my global site is only running PHP 4.4.9, whereas my localhost is on 5.2.5 – I don’t know if this has any effect on your plugin, I’m sure you might be able to answer that.

          I think my host can switch back and forth between PHP versions; I’ll write them to confirm this, then test the plugin again to see if its the PHP version.

          Clearly it might be more complicated than I thought.

          • DD32 says

            I don’t think it’ll be the fault of the PHP version, But if it is, I’ll have to take that into consideration.

            Is your local test server linux or windows?

          • nick says

            My localhost is WinXP running xampplite for Apache/MySQL/PHP

  15. Brian says

    I am getting the following error when try to Import media:

    Catchable fatal error: Object of class WP_Error could not be converted to string in /home/content/b/r/t/brtutor/html/wp-content/plugins/add-from-server/add-from-server.php on line 136
    I am using the latest version of WP and the Add-From-Server plugin.

    • DD32 says

      Looks like you’ve got an error with your upload directory, wp-content/uploads/ is probably not writable by the server i’d say.

      Does the standard WordPress uploader work?

      I can release an update for it to correct that error condition, But to be honest, i’m not going to bother right now.. I’ll see if any other conditions need checking next week. If you can fix the underlying error with your server, then the plugin should skip that error condition check.

      • Brian says

        The standard WP uploader did not work – I also made sure the directory was 777 and it was and it still didn’t work.

        Here is the solution –
        Goto Settings -> miscellaneous
        In “Store uploads in this folder” I for some reason had it set to “/videos” and it needed to changed to the default of “wp-content/uploads”

        Just to be helpful, it would be cool in your code to tell the user to check that setting.

        • DD32 says

          Except it doesnt matter what thats set to, as long as its set to something valid.

          /videos isnt a valid path that would be useable on your server.. ‘videos’ without the slash would’ve worked however.

          • Brian says

            Yup, I figured that out. I just named it “videos” and that worked.

            I wish there was a quick way to index all my media on a web page right after I upload new media to “video”. It still a pretty manual process to create the hyperlinks to the videos after I upload them to the server.

  16. nick says

    I find your plugin very useful, but have just upgraded to Wordpress 2.8.5, and now it no longer works…. Any suggestions to get it working again?

    • Sean says

      Running into the same issue, also running on the 2.8.5 release of WP. When I try the wp-admin/media-new.php?page=add-from-server function, I get the error “You do not have sufficient permissions to access this page.” Guessing something in the 2.8.5 security updates is blocking the plugin again.

      • DD32 says

        Starting from wordpress 2.8.4, WordPress no longer allows “Unfiltered Uploads” that meaning, That uploads may only be of a small set of “valid” upload types.. (And Admins must install a plugin to allow other types of files..)

        See http://core.trac.wordpress.org/ticket/10692 for info on why..

        The solution to re-enable it is to add this to your wp-config.php file:
        define(‘ALLOW_UNFILTERED_UPLOADS’, true);

        While i wasnt planning on releasing an update for this, I am going to release another version shortly, There is a huge but however, It’ll allow any user who can upload files to have access to it.. which is not what some people will want, But until the next major release, thats what i’ll be doing.

        • DD32 says

          Version 2.2 should be showing up in the next few hours for most people.

  17. scruss says

    Auto-upgrade has hosed my dashboard:

    “Warning: include(inc/class.dd32.php) [function.include]: failed to open stream: No such file or directory in /homepages/26/d89912342/htdocs/wordpress/wp-content/plugins/add-from-server/add-from-server.php on line 36

    Warning: include() [function.include]: Failed opening ‘inc/class.dd32.php’ for inclusion (include_path=’.:/usr/lib/php5′) in /homepages/26/d89912342/htdocs/wordpress/wp-content/plugins/add-from-server/add-from-server.php on line 36

    Fatal error: Class ‘DD32′ not found in /homepages/26/d89912342/htdocs/wordpress/wp-content/plugins/add-from-server/add-from-server.php on line 51″

    • DD32 says

      Yep, Sorry about that, Supid wordpress.org package manager screwed up. 2.2.1 was released shortly thereafter, but might be delayed..

      • scruss says

        No harm done. Just deleted the plugin, then cleared my page cache. Will reinstall again when I really need it.

  18. Francisco says

    I would like “move” the file ( delete the file in the orignal folder after copy it to /upload folder .

    Can I change the plug-in ? how ?

    Thanks very much

    • DD32 says

      If the uploaded file exists within the uploads folder to start with, it’ll simply be added as is. If it exists outside of the uploads directory, it will be copied there. Sorry, but i cant help explain where to change it to move instead of copying right this instant – my only suggestion is to upload to the uploads directory, and then import.

  19. nguyen says

    ed to this post on 22 November, 2009

    [...] I have uploaded a video to the media manager on Wordpress (I had to use the Add from Server plugin) as php.ini has a 2MB upload limit and then the media manager had a problem crunching a [...]

  20. Luke says

    Hi

    Thanks for the plugin! I’m having a problem using it with m4b files tho and get this message:

    “Walk One – Clip_1.m4b was not imported due to an error: File type does not meet security guidelines. Try another.”

    Anything you can do?

    Luke

  21. Miklas Njor says

    Hi Dion.

    Just tried the plugin and it works great. I was wondering if there is a way to set it to watch folder automaticly and import new files when they are added.

  22. twincascos says

    Hi, I’ve just been looking at this plugin and found that the lack of images in the list of images makes it difficult to know what the image is.
    So I’ve just added a little hack to show the image in the image list (scaled down with html).
    Not sure where to post the code, or if your interested in adding it to this plugin.
    Thanx,,

Continuing the Discussion

  1. Mediathek - Bilder direkt vom Server nutzen - mittmanns.com - ein privates Web-Blog linked to this post on 31 March, 2008

    [...] Abhilfe schafft das Plugin -Add From Server-, welches einem bequemen Zugriff auf alle am Server liegenden Dateien bietet und diese auch in die [...]

  2. Mediathek - Bilder vom Server laden - dorf-meinsberg.de - ein privates Web-Blog linked to this post on 31 March, 2008

    [...] Abhilfe schafft das Plugin -Add From Server-, welches einem bequemen Zugriff auf alle am Server liegenden Dateien bietet und diese auch in die [...]

  3. FEED.NIO.NAME » Add From Server linked to this post on 9 April, 2008

    [...] Visit [...]

  4. The Best Blogging Software (WordPress) + The Top 60 WordPress Plugins | Midas Oracle .ORG linked to this post on 13 April, 2008

    [...] Add From Server 1.2 » Dion Hulse (url) Plugin to allow the Media Manager to add files from the webservers filesystem. Note: All files are copied to the uploads directory. [...]

  5. WP Plugin Archive » Add From Server linked to this post on 7 June, 2008

    [...] allerdings nur Dateien verwalten, die über per WordPress hochgeladen wurden. Dank dem Plugin Add From Server können nun beliebige Verzeichnisse nach Dateien die per FTP hochgeladen wurden durchforstet [...]

  6. links for 2009-10-17 linked to this post on 18 October, 2009

    [...] Add From Server – blog://dd32.id.au/ “Add From Server” a WordPress plugin which allows you to browse the filesystem on the webserver and copy any files into the WordPress uploads system, Once “imported” it’ll be treated as any other uploaded file, and you can access it via the Media Library. (tags: wordpress filesystem pluginTE) [...]

  7. Media | Grassroots Soccer linked to this post on 22 November, 2009

    [...] I have uploaded a video to the media manager on Wordpress (I had to use the Add from Server plugin) as php.ini has a 2MB upload limit and then the media manager had a problem crunching a [...]

  8. media » Yabbox linked to this post on 22 November, 2009

    [...] I have uploaded a video to the media manager on Wordpress (I had to use the Add from Server plugin) as php.ini has a 2MB upload limit and then the media manager had a problem crunching a [...]

  9. Wordpress plugin for importing Media Library items in bulk « ActionPress! linked to this post on 11 February, 2010

    [...] Add From Server – Plugin to allow the Media Manager to add files from the webservers filesystem. Note: All files are copied to the uploads directory. [...]

  10. Adding large files to WordPress media library via ftp or file upload | Cyber Innovation linked to this post on 13 February, 2010

    [...] login to your WordPress Dashboard and add the plugin “Add to Server” from Dion [...]



Some HTML is OK

or, reply to this post via trackback.