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

Image Uploads - Migrating to new server

New Here ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Migating to a new server, and getting an error when uploading a new photo.  Any help appreciated.   Here is my code:

<cffile action="upload" filefield="Photo" destination="#ExpandPath ('../images/temp/')#" nameconflict="MakeUnique">
<cfset Photo = File.ServerFile>
<cfset NEWPHOTONAME = 'VE_' & '#dateformat(now(), 'yyyy_mm_dd_')#' & '#timeformat(now(), 'hh_mm_ss_')#' & '#photo#'>
<cffile action="rename" source ="#ExpandPath ('../images/temp/#photo#')#" destination="#ExpandPath ('../images/original/#NEWPHOTONAME#')#">
<cfset Photo = "#NEWPHOTONAME#">

 

Server doesn't like the #ExpandPath ('../images/temp/#photo#')# reference.

 

Error message:  The value of the attribute source, which is currently C:/HOSTINGSPACES/virginia/virginiaequestrian.com/wwwroot/images/temp/IMG_2123.JPG, is invalid.

 

Checking the folder, the file was uploaded to the correct "temp" folder, and is in fact there. Any help appreciated!

Views

326

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 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

So if you are on the server, and drop that value (C:/HOSTINGSPACES/virginia/virginiaequestrian.com/wwwroot/images/temp/IMG_2123.JPG) into the address bar of your browser, the image appears?

 

If not, it would seem there's something confusing you in thinking "it is there". If it DOES work, then it would be odd indeed that cf can't see it, since cf created it (on the upload).

 

In that case, you may want to assess what the permissions are for that folder, for the user running cf. If it's a service, does it show running as the user "local system" or something else? 


/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 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

My understanding is there are two different paths:

- one that is a URL, which could be pulled from the browser

- the other is the actual physical location of the file to be manipulated

 

On the old/current server,  #ExpandPath ('../images/temp/')# renders

D:\Docs\VirginiaEquestrian\images\temp\

 

New server, #ExpandPath ('../images/temp/')# renders

C:\HOSTINGSPACES\virginia\virginiaequestrian.com\wwwroot\images\temp\

 

My guess is it could be a file folder permissions issue.  Will check with my sys admin for his insights.

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 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Here is my workflow:

1.  Upload the file to a temp directory

2.  Rename the file so that it is unique (I append the file name with date/time)

3.  Deposit the newly named original into an "original" folder

4.  Resize the file in the "original" folder into a thumbnail and full sized image (using ImageMagick)

5.  Deposit the thumb/full sized image into the proper directories

My understanding is that I need to use ExpandPath to tell ImageMagick where the file actually lives on the server (not a relative URL)

 

Hopefully conveying this correctly.  Again, any help appreciated.

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 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

And here is the URL to the file that was uploaded:

http://virginiaequestrian.com.wc05.domainhosting.net/images/temp/IMG_2123.JPG

Here is the location that is returned with the ExpandPath command:

C:/HOSTINGSPACES/virginia/virginiaequestrian.com/wwwroot/images/temp/IMG_2123.JPG

Putting that absolute path in a browser shouldn't work, and in fact does not.

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
Community Expert ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

It should work. Especially because the file was successfully uploaded.

 

In any case, I have two suggestions:

  1.  Verify that the directory structure is correct.
    /wwwroot/
        /workingDir/
        /images/
    where workingDir and images are subdirectories, each one level deep under wwwroot. WorkingDir (my naming)  is the directory that contains the CFM page that runs the file-upload tag. The directory /images/ contains the subdirectories /temp/ and /original/.
  2. Simplify the code. For example, as follows:
    <cfset tempFolder=expandPath ('../images/temp')>
    <cfset originalFolder=expandPath ('../images/original')>
    	
    <cffile action="upload" filefield="Photo" destination="#tempFolder#" accept="image/jpeg,image/jpg,image/pjpeg,image/png" nameconflict="MakeUnique" >
    
    <cfset photoName = file.ServerFile>
    <cfset photoSource = tempFolder & "/" & photoName>
    
    <cfset newPhotoName = 'VE_' & dateformat(now(), 'yyyy_mm_dd_') & timeformat(now(), 'hh_mm_ss_') & photoName>
    <cfset photoDestination = originalFolder & "/" & newPhotoName>
    
    <cffile action="rename" source ="#photoSource#" destination="#photoDestination#">​

 

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
Community Expert ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Chuck, you have misunderstood me. See the first sentence in my first comment: "So if you are on the server, and drop that value...into the address bar of your browser, the image appears?"

 

You were saying that the value (used as the SOURCE for the rename) DOES exist, though CF said it was "invalid".

 

My suggestion was a way to prove whether it DOES exist, and then to help perhaps identify where the problem may be. 


/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 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Hi Charlie,

 

Thank you for your insights and input.  I have worked through many of the issues, and am able to successfully upload an image, copy it to the proper directory.  Now I am running into an issue that seems to be tied to cfexecute.  I am using ImageMagick to resize the images, and this issue seems to be tied to this operation.

The following is the internal exception message: access denied ("coldfusion.tagext.GenericTagPermission" "cfexecute")
java.security.AccessControlException: access denied ("coldfusion.tagext.GenericTagPermission" "cfexecute")

 

Thank you for any input or advice.

 

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
Community Expert ,
Jun 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Glad you got the other issues sorted.

 

And as for that error, sadly it's what you get when the person running the CF server has restricted the ability to use that tag, which can be done in the CF Admin via its Security>Sandbox Security page (or in older CF versions, it was called "Resource Security" in CF Standard). Whether you will be able to use it depends on a few things...

 

Is this a shared host you are on? If so, I doubt they will allow for you to use it, as it's regarded as being potentially dangerous.

 

If it's an organizational server, perhaps you could persuade the person responsible for the CF Admin.

 

I will note that the sandbox security feature can either be configured to apply to ALL CF apps, or it can be configured to allow for use of a specific tag like that (which might otherwise be blocked) if it's run from a specific directory that has been given permission (in the CF Admin, sandbox security configuration). 

 

Again, if you're on a shared host, I doubt they will do it. In an organizational server, they may be persuaded. They may also think "it can't be done" for CF Standard, if that's the license they have, but that limitation was lifted from being Enterprise-only in CF11.

 

Hope that helps.


/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 21, 2021 Jun 21, 2021

Copy link to clipboard

Copied

Thanks Charlie,

 

You are awesome for the quick responses.  From what I'm seeing, it looks like I can avoid using ImageMagick, which we used "back in the day" to resize photos, rotate them, etc.   It looks like I can most likely get the same results using cfimage, so I'm going to dive in.  

Very much appreciate your input.  Invaluable!

 

Cheers,

Chuck

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
Community Expert ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

Thanks for the kind regards, Chuck. And yep, most find that the image processing in CFML suffices to replace 3rd party solutions folks have long used. Of course, sometimes there may be some specific thing they want that the CF feature does NOT add. To each their own, and nice that we can have choices. 🙂

 

I will say that as you explore the world of CF's image processing, do beware that there can be a performance problem due to their decision (in CF8) to make the default "interpolation" to be "highestquality", which can really slow down some image processing--for what is to most eyes a negligble visual benefit. The opposite value is "highestperformance", and there are other values between. This is supported as an attribute in some CFIMAGE actions and as an arg in some of the image functions. For more, see a post I did some years ago, which still applies today.


/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
Community Expert ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

quote

 I have worked through many of the issues, and am able to successfully upload an image, copy it to the proper directory. 


By @chuckebbets2

I am glad to hear that. Would you, for the benefit of the forum, please share your solution. It will certainly help a fellow developer in future.

 


Now I am running into an issue that seems to be tied to cfexecute.  I am using ImageMagick to resize the images, and this issue seems to be tied to this operation.

The following is the internal exception message: access denied ("coldfusion.tagext.GenericTagPermission" "cfexecute")
java.security.AccessControlException: access denied ("coldfusion.tagext.GenericTagPermission" "cfexecute")

 


There is an alternative cause, if it is not the sandboxing that Charlie mentioned. It is likely that your code is trying to gain unauthorized access to a file or folder of the Operating System. Could you share the code? 

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 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

I am using CF_MagickTag - it calls the ImageMagick application.   Long story, but its used to manipulate images.  I have achieved the same end results (resizing, allowing the user to rotate the image, etc) with cfimage.  All good in the hood!

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
Community Expert ,
Jun 22, 2021 Jun 22, 2021

Copy link to clipboard

Copied

BKBK, I'm almost 100% certain tha tthat error message (about generic tagpermission) is ONLY if the tag is itself blocked by the sandbox/resource security, rather than being about inability to access any file named in the tag (or in this case, the path to the command being executed in cfexecute, or any file it is accessing). 

But if anyone somehow finds otherwise, please do share.


/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
Community Expert ,
Jun 26, 2021 Jun 26, 2021

Copy link to clipboard

Copied

LATEST

Charlie, I do believe <cfexecute> is designed to throw a java.security.AccessControlException if the user that ColdFusion is running as doesn't have the required access or permission to do the "execute". 

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