Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload Binary File to Database without Putting it on the File System

Status
Not open for further replies.

Glowball

Programmer
Oct 6, 2001
373
0
0
US
I think that I should be able to do this, but I'm not sure how. I have ColdFusion 7 and Oracle 9i, and I want to store binary files in the database. However, I cannot write to the file system -- it's technically impossible. The only way I can do it is if there is no file system storage involved, however temporary.

For example, I need to upload the file into a variable, and then dump the variable contents into the database.

Everywhere I've read, you have to store it temporarily in the file system first. Is this a requirement? Can CFFILE take a variable name as the destination? Has anyone done this before?

Thanks!
 
I cannot write to the file system -- it's technically impossible.

Perhaps I am misunderstanding, but if you cannot write to the file system, I do not see how you could use cffile at all. By the time you call <cffile action="upload" ..>, the uploaded file is already on the file system. Albeit contained in a temporary file. <cffile action="upload" ..> essentially moves the file to the correct destination, renames it, etcetera.

Assuming that part is not an issue, I suppose you could always try reading temporary file into a variable using <cffile action="readBinary">. Though I do not know how advisable that is ..




----------------------------------
 
Hmm, I'll have to do some testing to see if it will let me do the upload from the form but then not handle the file. I didn't realize that it was already on the file system when <cffile> was called (I thought it was held in a variable and <cffile> stored it to the system).

I'll see how far I can get with it. The issue is that because we aren't allowed to write to the file system I figured I would store files in the database instead. But then I've hit this snag.

I'll post up again after more testing. Thanks!
 
to see if it will let me do the upload from the form but then not handle the file

Yes, it would be interesting to see what happens. If that is the case you might have a chance using <cffile action="readBinary"> on the temporary file name.

I will check back tomorrow.

----------------------------------
 
I did some testing and it looks like I can't upload to any folder other than the temp folder that is already set up -- so I can get the files into the database. I'd only tried to upload to another folder before, and then I was told that uploading wasn't allowed. So I'm good to go.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top