简体   繁体   English

在 Linux 上使用 Coldfusion 写入 USB flash 驱动器

[英]Using Coldfusion to write to a USB flash drive on Linux

I am trying to write a file to a USB drive located at /media/user/drive_name我正在尝试将文件写入位于 /media/user/drive_name 的 USB 驱动器

The directory I am working in is /var/www/html/site_folder我正在工作的目录是 /var/www/html/site_folder

<cffile action="write" file="../../../../media/user/drive_name/hello.txt" output="hello">

I get "Parent directory for /media/user/drive_name/hello.txt doesn't exist"我得到“/media/user/drive_name/hello.txt 的父目录不存在”

I have tried reading the file and it tells me it is not a file.我试过读取文件,它告诉我它不是文件。

Anyone have experience with this?有人有这方面的经验吗?

This throws an error:这会引发错误:

<cffile action="write" file="../../../../media/user/drive_name/hello.txt" output="hello">

Parent directory for /media/user/drive_name/hello.txt doesn't exist /media/user/drive_name/hello.txt 的父目录不存在

But this returns permission info:但这会返回权限信息:

<cfdump var="#getFileInfo("/media/user")#">

Your initial code is trying to reference the /media folder / drive from a relative path.您的初始代码试图从相对路径引用/media文件夹 / 驱动器。 On Linux, you should be able to access a root / mount folder directly from the main directory.在 Linux 上,您应该能够直接从主目录访问根 / 挂载文件夹。

Can the server read this file?服务器可以读取这个文件吗?

<cffile action="read" file="/media/user/drive_name/hello.txt" variable ="content">

Thank you Adrian J Moreno for your reply.谢谢阿德里安·莫雷诺的回复。 Yes I had tried it both relative and absolute and neither worked.是的,我已经尝试过相对的和绝对的,但都没有奏效。 What did finally work is we had to run Lucee as the root user which gave it permission.最终起作用的是我们必须以授予它权限的 root 用户身份运行 Lucee。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM