1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

[SOLVED] Symlink file upload error

Discussion in 'Community' started by vladimir84, Dec 15, 2018.

  1. vladimir84

    vladimir84 Member

    Level: Community
    Joomla is on Win2012 R2, XAMPP.
    I created a symlink like so:

    C:\Users\Administrator>mklink /D "C:\xampp\htdocs\pdf" "Z:\"
    symbolic link created for C:\xampp\htdocs\pdf <<===>> Z:\

    When I point the file upload element to the above directory, and I try to add a new record, there is the following error:
    JFolder: :folder: Path is not a folder.
    Needless to say that even though it shows the form, it doesn't save it.

    I did this so that I can save the PDFs on a LAN location.

    I basically spent the whole day looking for a solution on stackoverflow. Any thoughts?
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Unfortunately, there's not much I can do about this. J!'s JFolder library uses PHP's is_dir() to check if a folder exists, and is_dir() doesn't understand Windows symlinks. The only way to get PHP's is_dir() to work with a Windows share is to use the UNC path, like '//server/path/to/folder', which obviously doesn't fit with the way Fabrik / J! builds paths relative to the J! root.

    Afaik, it works on UN*X. I've not tested network shares on symlinks, but I've used symlinks to point to folders outside of the web root, and those work on Linux. But Windows symlinks are a mess, and just don't play well with PHP.

    There's a chance I could re-write out file system adapter in the upload element to avoid using JFolder, but at the moment I have no way of testing it. I've been fighting for a year now with Windows 10 on my laptop and my server, to get network shares mapped. When they did away with the "home group" in Windows 10, it completely screwed up my networking. I've spent countless hours trying to get my laptop to be able to map shares from a Windows 10 Pro server (mostly acts as my media server), with no luck - and judging by the thousands of threads out there about the same issues, I'm not the only one.

    -- hugh
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    So, ironically, I suspect that if you ran your J! in a Linux VM in something like VirtualBox, instead of native, using Samba to map your shared drive, it would probably work. :(

    -- hugh
     
  4. vladimir84

    vladimir84 Member

    Level: Community
    Thanks Hugh, indeed, I saw on some answers that linux had that. I guess I have to make that PHP upload form after all. I'll use the secondary MySQL table to point to PDFs.
    But first, I'll try to comment out the is_dir() in Joomla, and see if it will work.

    Thanks again for the help.
    Best wishes.
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I strongly advise against commenting that out in the J! folder library, as it could have some nasty side effects.

    If I get a little time in the next day or two, I'll see if there's some way I can finagle testing this. There must be SOME way I can test. Maybe if I just test with a simple symlink to a local folder. Thinking about it, for the purpsoes of this test it shouldn't matter if the target of the symlink is local or a network share.

    -- hugh
     
  6. vladimir84

    vladimir84 Member

    Level: Community
    Yeah, I had the same thought when I saw how deeply integrated it was, I will not be doing it.
    Thank you. If there is anything I can do to help let me know.

    I just tried mklink /J (junction directory) which does work, without any problems. I successfully pointed to a local folder C:\test1 and all the uploaded files are there. I guess this is useful to people who use external HDDs attached to the server

    I'm still looking for a way to upload to a network drive.
     
  7. vladimir84

    vladimir84 Member

    Level: Community
    Hugh, I did it!!!
    Praises to:
    https://stackoverflow.com/questions/21616431/using-mklink-command-with-network-drives
    (I also did the suggestion n. 2 of the post first
    fsutil behavior set SymlinkEvaluation L2R:1
    so I'm not sure if it will work without it)

    Like he said, just create 2 symlinks in Windows! :D
    mklink /D D:\shareLink \\network\share
    mklink /J D:\junctionLink D:\shareLink

    In my case, I created a /D link to a linux server on a local network that the account can access
    and
    create a /J link to that /D link pointing to a htdocs/joomla/pdf
    and all you have to do at the end is to say element - file upload, destination /pdf
    and it works!!

    If users follow these simple instructions, they can save and retrieve all their files on any server they want.
    :):):)

    Be very very careful when removing the symbolic links in Windows!
    ref: https://superuser.com/questions/167076/how-can-i-delete-a-symbolic-link
    You have to use rmdir for links created with /J, otherwise if you delete them with a "del" key, the directory and its files will be deleted.



    Should I document this in the wiki?
     
    Last edited: Dec 17, 2018
  8. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Yay!

    If you feel super helpful, maybe you could add a section to the upload element wiki about that?

    I actually just came here to suggest that approach. I tried using a symlink to a local folder, and it worked, then some more googling turned up the same Stack Overflow thread you found. I just couldn't test it, as I still can't create network shares to my server. I can access \\server\path as a UNC, but it stubbornly refuses to let me create an actual drive share.

    -- hugh
     

Share This Page