homma Posted August 10, 2017 Share Posted August 10, 2017 How can I upload files without changing the original filenames? I use processwire in English and Japanese. When I upload a file, the filename is sanitized and changed to an alphanumeric name. I need some files to be uploaded with original filenames with Japanese characters (2-byte characters). Is there a good way to do this? Thanks in advance, Yu Link to comment Share on other sites More sharing options...
Gideon So Posted August 10, 2017 Share Posted August 10, 2017 Hi, ProcessWire doesn't support non alpha numberic file name. I have made a feature request in within and waiting Ryan implement it but seems that he has no plan to do it in the near future. Gideon Link to comment Share on other sites More sharing options...
homma Posted August 11, 2017 Author Share Posted August 11, 2017 Hello Gideon, Thanks for your message. It's a pity that non-alphanumeric filenames are not supported. I need to integrate another file management system just because of this. Wordpress has a option to keep the original filenames, but I really want to use Processwire for my project. @ryan, do you have any plan to implement this feature, in the core or plugin (or anything)? Yu Link to comment Share on other sites More sharing options...
abdus Posted August 11, 2017 Share Posted August 11, 2017 Have you tried serving file with PHP instead of just linking it? You can change the filename using HTTP headers this way https://stackoverflow.com/a/1628281 2 Link to comment Share on other sites More sharing options...
bernhard Posted August 11, 2017 Share Posted August 11, 2017 On 8/10/2017 at 4:15 PM, homma said: I need some files to be uploaded with original filenames with Japanese characters (2-byte characters). Expand may i ask WHY? if we know the reason we may can suggest some other way of achieving almost the same need Link to comment Share on other sites More sharing options...
homma Posted August 11, 2017 Author Share Posted August 11, 2017 Hello all, Thank you for your advice! @bernhard, the reason is that I need to let users download files with Japanese filenames. So, as @abdus suggested, if I can change the filename to, for example the value in 'Description' field of the file, it is OK. I don't need to keep original filenames on the webserver. Would you advice me how I can do this? Thank you! Yu Link to comment Share on other sites More sharing options...
bernhard Posted August 11, 2017 Share Posted August 11, 2017 you could just take the code example from abdus, activate url segments for your site and do something like this: // list your files to download foreach($page->files as $i=>$file) { echo '<a href="' . $page->url . $i . '" target="_blank">Download File ' . ($i+1) . '</a>'; } and in your template file: if($num = $input->urlSegment1) { $file = $page->files->eq($num); // continue with abdus script } maybe not without bugs but should show one possible solution Link to comment Share on other sites More sharing options...
abdus Posted August 11, 2017 Share Posted August 11, 2017 Although browser support is not perfect, you can also use anchor links with download attribute to force download with a certain filename. <a href="link/to/my/file/with/a/name/i/dont/like.jpg" download="MyFile.jpg">Download</a> https://stackoverflow.com/a/32676793 Link to comment Share on other sites More sharing options...
homma Posted August 11, 2017 Author Share Posted August 11, 2017 Thank you @bernhard and @abdus ! The download attribute is very simple and easy, but I'm not sure I can ignore IE. I'll work on this and come back with (hopefully good) results Yu Link to comment Share on other sites More sharing options...
Gideon So Posted August 11, 2017 Share Posted August 11, 2017 Hi @homma, Someone posted a solution in github. I tested it and it works fine. The downside is that you have to modify the core of ProcessWire which mean you have to do it again every time you upgrade your core. https://github.com/processwire/processwire-requests/issues/56#issuecomment-263669255 Gideon 2 Link to comment Share on other sites More sharing options...
adrian Posted August 11, 2017 Share Posted August 11, 2017 @homma - here is some reading on this issue: https://github.com/processwire/processwire-requests/issues/56 (sorry, @Gideon So already linked to this) 2 Link to comment Share on other sites More sharing options...
homma Posted August 11, 2017 Author Share Posted August 11, 2017 Hello @Gideon So and @adrian, Thank you for sharing the github link. I quickly read the threads and noticed some people have the same concern. I wanted to test the modified core file, but the Dropbox link seems to expire now. Do you happen to have a copy? I currently try the solution bernhard and abdus suggested, but it turns out simply use Content-Disposition doesn't work on some browsers. I'm looking at this code now, which partially solve my problem.http://qiita.com/mpyw/items/202bef4349bfdc7e5c13#_reference-20f16504015c97498dc5 (article in Japanese) Yu Link to comment Share on other sites More sharing options...
Gideon So Posted August 12, 2017 Share Posted August 12, 2017 On 8/11/2017 at 2:42 PM, homma said: Hello @Gideon So and @adrian, Thank you for sharing the github link. I quickly read the threads and noticed some people have the same concern. I wanted to test the modified core file, but the Dropbox link seems to expire now. Do you happen to have a copy? Yu Expand Hi @homma, Yes. I do keep a copy here. It is for 3.0.42. I am not sure whether it works with the latest version. Gideon ProcessWireUploadDemo.zip 1 Link to comment Share on other sites More sharing options...
homma Posted August 13, 2017 Author Share Posted August 13, 2017 Thank you @Gideon So! I tested it and it worked quite well. I really hope this feature is realised in the core... Yu 2 Link to comment Share on other sites More sharing options...
Gideon So Posted August 15, 2017 Share Posted August 15, 2017 On 8/13/2017 at 3:18 AM, homma said: Thank you @Gideon So! I tested it and it worked quite well. I really hope this feature is realised in the core... Yu Expand Hi @homma, Glad that it works for you. Which version of ProcessWire you use?? Gideon Link to comment Share on other sites More sharing options...
homma Posted August 15, 2017 Author Share Posted August 15, 2017 On 8/15/2017 at 3:12 AM, Gideon So said: Hi @homma, Glad that it works for you. Which version of ProcessWire you use?? Gideon Expand Hello @Gideon So, I'm using PW 3.0.62 (stable). Yu Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now