Jump to content

How to upload files without changing original filenames


homma
 Share

Recommended Posts

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

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

16 hours ago, homma said:

I need some files to be uploaded with original filenames with Japanese characters (2-byte characters).

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

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

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

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

11 hours ago, 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

 

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

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...