• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating a File Shortcut with CF

New Here ,
Jun 17, 2019 Jun 17, 2019

Copy link to clipboard

Copied

I am finding and uploading documents with this code:

<cfif structKeyExists(form, "uploadfile1") and len(form.uploadfile1)>

   <cfset destination = "//server/target folder/">

   <cffile action="upload" filefield="uploadfile1" destination="#destination#" nameConflict="makeUnique">

</cfif>

However, I would also like to create Shortcuts to this file in one or more other folders. In Windows Explorer, shortcut entries look like this:

MyFile.docx - Shortcut          6/17/2019 1:40 PM          Shortcut          3 KB

Is there a way to do this in CF? If so, can you provide some code or a location where I can find some advice on how to do it? I use Dreamweaver CS6 as my development environment.

Thanks.

TOPICS
Builder

Views

348

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2019 Jun 17, 2019

Copy link to clipboard

Copied

So to be clear, is what you mean that you would like to have CF *automatically* create that shortcut for you, after the upload, pointing to the uploaded file? There's no built-in feature to do what you want. There may be options to consider, such as something that's run from within CFML and AFTER the upload, but the options do come with challenges.

First, even Windows does not offer a built-in way to create shortcuts "manually" (using other than Windows Explorer, I mean).

Next, the shortcut would be intended to be placed on your client machine from which you did the upload, right? And (this is most important) is CF running on the same machine?

If so, one thing you could do would be to call a command-line tool to create the shortcut, from within CF, to save the shortcut. CF can call command-line tools using CFEXECUTE, but it's usually challenging for first-timers.

As for Windows command-line tools to create a shortcut, again there's none built-in (see this helpful discussion of that and alternatives, https://superuser.com/questions/392061/how-to-make-a-shortcut-from-cmd). It seems perhaps the best solution for you would be a free tool from Nirsoft (makers of many nice, free Windows tools), called .NirCmd​. And to use it, the option would be: nircmd.exe cmdshortcut. See the discussions of the tool at both the aforementioned links.

Then do some searching for how to use CFEXECUTE.

And if you meant that the CF was on ONE machine and the client was on another, it would be much more challenging to create and send the shortcut back (you may be able to with CFCONTENT), but then there is also the question of what the path to the file would be FROM THE CLIENT as opposed to what it is AS CF SEES IT.

As I said from the outset, there will be challenges with what you seek. It's not an innate feature (of CF or Windows), and I'd never heard anyone ask for this in my 22 years of working with CF. But this MAY be a solution for you.

Or perhaps someone else will propose one I'm not thinking of. Let us know what you think of the above.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 17, 2019 Jun 17, 2019

Copy link to clipboard

Copied

LATEST

Charlie,

Working all this out is probably above my pay grade, but since you went to so much trouble, let me at least be a bit more clear: CF is running on a Coldfusion server somewhere. A user sits at their local machine and runs a CF script that prompts them to select a file on their local machine, which the code I quoted then copies to a location on a different server. Now there are a couple of other folder locations on different servers where I would like to create a Shortcut to that file rather than copy another copy into those folders.

Your answer provides me with some hints I can work on tomorrow (I'm off now), though I am not hopeful. If I could execute a VBA script with CFEXECUTE, I might be able to pull this off. I don't know VBA, but someone here does.

Anyway, thanks. I may have more questions/comments tomorrow. I very much appreciate your help

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation