[英]rails how can you convert / to \ in a file name
I am working on selecting files to email and then passing them to the user's notes email client. 我正在选择要发送电子邮件的文件,然后将它们传递给用户的便笺电子邮件客户端。
The string I want to send to the system command should be in the format of: 我要发送给系统命令的字符串应采用以下格式:
"C:\\Program Files (x86)\\IBM\\Lotus\\Notes\\notes.exe" Mailto:chris@mydomain.com?Subject=MailSubject?Attach=C:\\test.bat
“ C:\\ Program Files(x86)\\ IBM \\ Lotus \\ Notes \\ notes.exe” Mailto:chris@mydomain.com?Subject = MailSubject?Attach = C:\\ test.bat
However, the code 但是,代码
$attached_files = $attached_files + "?Attach="+ Rails.root.to_s + "/public/images/" + document.id.to_s + "/" + document.doc_file_file_name
gives me forward slashes instead: 给我反斜杠:
C:/Users/cmendla/RubymineProjects/technical_library/public/images/2/High_Durability.pdf
C:/Users/cmendla/RubymineProjects/technical_library/public/images/2/High_Durability.pdf
When that is passed to system() it won't launch the notes email. 将其传递给system()时,它不会启动注释电子邮件。 I think that the problem is that the server looks for / and the windows pc looks for \\
我认为问题是服务器寻找/而Windows pc寻找\\
Is there any way to easily change / to \\ at least for the time being for testing? 是否有任何方法可以轻松地将/更改为\\至少在目前进行测试?
Have you tried 你有没有尝试过
Rails.root.join("public","images", document.id, document.doc_file_file_name)
? ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.