Using Coldfusion to write to a USB flash drive on Linux

Viewed 77

I am trying to write a file to a USB drive located at /media/user/drive_name

The directory I am working in is /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"

I have tried reading the file and it tells me it is not a file.

Anyone have experience with this?

2 Answers

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

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. On Linux, you should be able to access a root / mount folder directly from the main directory.

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.

Related