homma

How to upload files without changing original filenames

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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 ;)

Share this post


Link to post
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

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thank you @Gideon So!

I tested it and it worked quite well. I really hope this feature is realised in the core...

Yu

  • Like 2

Share this post


Link to post
Share on other sites
On 2017/8/13 at 11: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

Hi @homma,

Glad that it works for you. Which version of ProcessWire you use?? 

Gideon

Share this post


Link to post
Share on other sites
2 hours ago, Gideon So said:

Hi @homma,

Glad that it works for you. Which version of ProcessWire you use?? 

Gideon

Hello @Gideon So,

I'm using PW 3.0.62 (stable).

Yu

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Clément Lambelet
      Hi all,
       
      I'm really new to ProcessWire, maybe I missed the solution in the documentation.
      I'm working on a site which involves a lot of image upload fields, and I'm always getting many timeout errors. I'm pretty sure it's because I generate too many variations on a single page load (around 20 images with 7 different sizes, for them to be responsive).
      I can't use ImageSizerEngineIMagick to help (my host doesn't support it).
       
      I was wondering if there was a way to hook to the process of client-side image resizing (https://processwire.com/blog/posts/processwire-3.0.63-adds-client-side-image-resizing/) to generate the different variations (as it seems really faster). If not, is there a way to generate the different variations on upload and not on page load ?
       
      Any ideas and suggestions are welcome!
    • By cosmicsafari
      Hi all,
      I am working on a site which involves a lot of image upload fields, 99% of the time it works perfectly but I have noticed that every so often image variations will be missing.
      Like the original uploaded image is fine but maybe 1 or 2 out of the variations is just blank.
      The variation files will appear within the assets folder but they will be just in name only without any actual image content.
      Since its quite a random thing I am finding it rather difficult to figure out why this happens?
      Any ideas?
    • By modifiedcontent
      It would be great if 'choose file' in the image field would be able to handle other input sources than only the client's OS file manager; Amazon S3/cloud storage, Dropbox, an image folder on an intranet, another folder on the same server where PW is installed, whatever.
      It would be super convenient if you could just upload images to a folder/directory in the templates folder or root, without any processing, and be able to access that as a source option in the image field. Any way to make that happen?
      I had started a thread about this here. BitPoet posted a very helpful partial solution specifically for Zenphoto, but it would be great if there was a more source agnostic solution built into Processwire.
      Letting Processwire download images from any external media gallery/repository would be a good alternative to having a full centralized Media Manager.
      Or am I missing something that would make this impossible/a bad idea?
      Edit: Robin S has a module that adds one alternative input option.
    • By SeoGuy
      Does anyone here have experience installing a translation module that creates new pages for multiple languages?
      I am assuming when these pages are generated, they are indexable by google as "new" and "fresh."
      Thoughts?
    • By jploch
      Hi!
      I have a problem with uploading animated GIFs again.
      The upload starts, but never finishes and just loads forever.
      Iam running PW 3.0.62 and have the Image Animated GIF Module installed.

      I also increased the memory limit in the htaccess file in PW root directory like this:
      <IfModule mod_php5.c>
      php_value memory_limit 256
      php_value upload_max_filesize 64M
      php_value post_max_size 64M
      php_value max_execution_time 300
      php_value max_input_time 1000
      </IfModule> 
      I had this problem before, but was able to fix it with the Animated GIF Module and the modification of the htaccess file.
      So maybe this is related to the provider (strato).
      Here is the error I get, when uploading the GIF (1.1 MB filesize)
      Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/wire/core/PWGIF.php on line 252 Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/site/assets/cache/FileCompiler/site/modules/ImageAnimatedGif/ImageAnimatedGif.module on line 285 Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/wire/core/PWGIF.php on line 252 Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/wire/core/PWGIF.php on line 252 Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/site/assets/cache/FileCompiler/site/modules/ImageAnimatedGif/ImageAnimatedGif.module on line 285 Warning: preg_match_all() expects at least 3 parameters, 2 given in /mnt/web216/a2/50/51925650/htdocs/processwire/wire/core/PWGIF.php on line 252 [{"error":false,"message":"Added file: test.gif","file":"\/processwire\/site\/assets\/files\/1098\/test.gif","size":101734,"markup":"<li id='file_daf280af792fd5b906511363ae2bc39d' class='ImageOuter gridImage ui-widget'><div class='gridImage__tooltip'><table><tr><th>Dimensions<\/th><td>500x333<\/td><\/tr><tr><th>Filesize<\/th><td>99&nbsp;kB<\/td><\/tr><tr><th>Variations<\/th><td>0<\/td><\/tr><\/table><\/div>\n\t\t\t<div class='gridImage__overflow'>\n\t\t\t\t<img src=\"\/processwire\/site\/assets\/files\/1098\/test.0x260.gif?nc=1509109293\" alt=\"\" data-w=\"500\" data-h=\"333\" data-original=\"\/processwire\/site\/assets\/files\/1098\/test.gif?nc=1509109293\" \/>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t<div class='gridImage__hover'>\n\t\t\t\t\t<div class='gridImage__inner'>\n\t\t\t\t\t\t<label for='' class='gridImage__trash'>\n\t\t\t\t\t\t\t<input class='gridImage__deletebox' type='checkbox' name='delete_thumbnail_daf280af792fd5b906511363ae2bc39d' value='1' title='Delete' \/>\n\t\t\t\t\t\t\t<span class='fa fa-trash-o'><\/span>\n\t\t\t\t\t\t<\/label>\n\t\t\t\t\t\t<a class='gridImage__edit'>\n\t\t\t\t\t\t\t<span>Edit<\/span>\n\t\t\t\t\t\t<\/a>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\n\t\t\t\t<div class='ImageData'>\n\t\t\t\t\t<h2 class='InputfieldImageEdit__name'><span contenteditable='true'>test<\/span>.gif<\/h2>\n\t\t\t\t\t<span class='InputfieldImageEdit__info'>99&nbsp;kB, 500&times;333 <\/span>\n\t\t\t\t\t<div class='InputfieldImageEdit__errors'><\/div>\n\t\t\t\t\t<div class='InputfieldImageEdit__buttons'><small><button type='button' data-href='\/processwire\/admin\/page\/image\/edit\/?id=1098&file=1098,test.gif&rte=0&field=thumbnail' class='InputfieldImageButtonCrop ui-button ui-corner-all ui-state-default pw-modal-large pw-modal' data-buttons='#non_rte_dialog_buttons button' data-autoclose='1' data-close='#non_rte_cancel'><span class='ui-button-text'><span class='fa fa-crop'><\/span> Crop<\/span><\/button><button type='button' data-href='\/processwire\/admin\/page\/image\/variations\/?id=1098&file=test.gif&modal=1&varcnt=varcnt_thumbnail_daf280af792fd5b906511363ae2bc39d' class='ui-button ui-corner-all ui-state-default pw-modal-large pw-modal' data-buttons='button'><span class='ui-button-text'><span class='fa fa-files-o'><\/span> Variations <span class='ui-priority-secondary'>(0)<\/span><\/span><\/button><\/small><\/div>\n\t\t\t\t\t<div class='InputfieldImageEdit__core'><div class='InputfieldFileDescription'><label for='description_thumbnail_daf280af792fd5b906511363ae2bc39d' class='detail'>Description<\/label><input type='text' name='description_thumbnail_daf280af792fd5b906511363ae2bc39d' id='description_thumbnail_daf280af792fd5b906511363ae2bc39d' value='' \/><\/div><\/div>\n\t\t\t\t\t<div class='InputfieldImageEdit__additional'><\/div>\n\t\t\t\t\t<input class='InputfieldFileSort' type='text' name='sort_thumbnail_daf280af792fd5b906511363ae2bc39d' value='1' \/>\n\t\t\t\t\t<input class='InputfieldFileReplace' type='hidden' name='replace_thumbnail_daf280af792fd5b906511363ae2bc39d' \/>\n\t\t\t\t\t<input class='InputfieldFileRename' type='hidden' name='rename_thumbnail_daf280af792fd5b906511363ae2bc39d' \/>\n\t\t\t\t<\/div>\n\t\t\t<\/li>","replace":true,"overwrite":0}]