11 Replies - 4290 Views - Last Post: 01 January 2009 - 08:25 PM Rate Topic: -----

#1 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Delete image from image gallery

Post icon  Posted 04 December 2008 - 12:54 PM

The error:

ColdFusion could not delete the file C:\ColdFusion8\wwwroot\orig_gallery\gallery\ for an unknown reason.
The error occurred in C:\ColdFusion8\wwwroot\orig_gallery\delete.cfm: line 1

The Code:

1 : <cffile action="delete" file="#uploads##lg_image#">
2 : <cfquery name="qDelete" datasource="z_gallery">
3 :	 DELETE FROM gallery



The question:

Does this syntax look proper? Not sure if it is correct. Thanks for any help you may be able to provide. When I select a file to delete from my image gallery this delete.cfm is called and attempts to delete the file from the folder where it is stored

uploads = C:\ColdFusion8\wwwroot\orig_gallery\gallery\

and the microsoft access database (lg_image is a column in the database)

Thank you!!

Is This A Good Question/Topic? 0
  • +

Replies To: Delete image from image gallery

#2 CR250  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 58
  • Joined: 14-June 08

Re: Delete image from image gallery

Posted 04 December 2008 - 01:22 PM

View Postmidasxl, on 4 Dec, 2008 - 11:54 AM, said:

C:\ColdFusion8\wwwroot\orig_gallery\gallery\


Check what your actually trying to delete a file or a whole directory.
Was This Post Helpful? 0
  • +
  • -

#3 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Delete image from image gallery

Posted 04 December 2008 - 01:41 PM

Thanks for responding. I'm trying to delete an image (.jpg) in the directory. The variables...

#uploads# = C:\ColdFusion8\wwwroot\orig_gallery\gallery\

and then

#lg_image# = image.jpg in the directory

I'm working on ColdFusion Developer Edition.

So those variable together like this #uploads##lg_image# should =

C:\ColdFusion8\wwwroot\orig_gallery\gallery\image.jpg

Should I be using the http://localhost:850...llery/image.jpg path instead?

Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 CR250  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 58
  • Joined: 14-June 08

Re: Delete image from image gallery

Posted 04 December 2008 - 01:46 PM

View Postmidasxl, on 4 Dec, 2008 - 12:41 PM, said:

So those variable together like this #uploads##lg_image# should =



Try

<cfset fileToRemove = uploads & lg_image />
<cffile action="delete" file="#fileToRemove#" />
Was This Post Helpful? 0
  • +
  • -

#5 f150b0508  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 25
  • Joined: 02-December 08

Re: Delete image from image gallery

Posted 04 December 2008 - 01:59 PM

Make sure you have the correct permissions set on the \gallery folder.
Was This Post Helpful? 0
  • +
  • -

#6 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: Delete image from image gallery

Posted 04 December 2008 - 04:48 PM

Quote

So those variable together like this #uploads##lg_image# should =

C:\ColdFusion8\wwwroot\orig_gallery\gallery\image.jpg


In addition to the suggestions above ... did you verify it actually does equal the right file path, and that there is not a trailing \ missing ? Use FileExists(...) to verify you have the right file path.

Also, can you delete any files from that directory? If not, it is probably a permissions problem like f150b0508 mentioned. If the problem is just with that one file, maybe the file is in use. IIRC, there was a bug with one of the Image functions that left files locked afterward, so you could not delete them. That might be it. But check the other things first.
Was This Post Helpful? 0
  • +
  • -

#7 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Delete image from image gallery

Posted 05 December 2008 - 06:15 AM

View Postf150b0508, on 4 Dec, 2008 - 12:59 PM, said:

Make sure you have the correct permissions set on the \gallery folder.


Thanks for the tip. Since I am using ColdFusion 8 Developer edition with the server located on my local machine how do I set the appropriate permissions on the folder?

The path to it on my local machine is

C:\ColdFusion8\wwwroot\gallery\gallery\images go here.jpg

I am familiar with setting CHMOD on a folder sitting on a remote server. Is the same type of thing? Thanks for your assistance!
Was This Post Helpful? 0
  • +
  • -

#8 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Delete image from image gallery

Posted 05 December 2008 - 06:21 AM

Another thing I've noticed is that it works at random times. I will upload an image and then successfully delete it. Then I will upload another image and successfully delete that one as well. On the third go around it will kick back an error telling me it cannot delete for an unknown reason. There is not pattern.
Was This Post Helpful? 0
  • +
  • -

#9 garyrgilbert  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 22-July 08

Re: Delete image from image gallery

Posted 05 December 2008 - 07:23 AM

View Postmidasxl, on 5 Dec, 2008 - 05:21 AM, said:

Another thing I've noticed is that it works at random times. I will upload an image and then successfully delete it. Then I will upload another image and successfully delete that one as well. On the third go around it will kick back an error telling me it cannot delete for an unknown reason. There is not pattern.


Firstly you should be checking the file system to see if the file exists before attempting to delete it. Secondly shouldn't be executing the database delete statement if an error occured, or if the file cannot be found or any other error.

if you installed CF on your local machine CF will have admin permissions so you really don't have to worry about that. and you should be using the full physical path to the file not the web path.

Lastly what is the delay between the upload and the attempted delete, sometimes the file system holds a lock on the file for a few seconds directly after uploading.

I would be interested in what the stack trace looks like from your error message, you do have robust error handling turned on in the CFadministrator right?
Was This Post Helpful? 0
  • +
  • -

#10 midasxl  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 191
  • Joined: 03-December 08

Re: Delete image from image gallery

Posted 05 December 2008 - 07:42 AM

I do have robust error handling enabled. It is quite informative. I am using the full physical path to the file as well, not the web path.

Again, there does not seem to be a pattern. I have uploaded and successfully deleted the file seconds later with no problem, but on other tries it errors out. I have uploaded and waited several minutes and then deleted successfully, and then tried again waiting the exact amount of time as the previous try and it errors out.

Here is the full error that robust error handling is showing me.

ColdFusion could not delete the file C:\ColdFusion8\wwwroot\orig_gallery\gallery\CTNC ARTHUR R. DEPEW.jpg for an unknown reason.  
 
  
The error occurred in C:\ColdFusion8\wwwroot\orig_gallery\delete.cfm: line 1
 
1 : <cffile action="DELETE" file="#uploads##lg_image#">
2 : <cfquery name="qDelete" datasource="z_gallery">
3 :	 DELETE FROM gallery

 

--------------------------------------------------------------------------------
 
Resources: 
Check the ColdFusion documentation to verify that you are using the correct syntax. 
Search the Knowledge Base to find a solution to your problem. 

 
Browser   Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.1) 
Remote Address   127.0.0.1 
Referrer   http://localhost:8500/orig_gallery/upload.cfm 
Date/Time   05-Dec-08 09:28 AM 
 
Stack Trace (click to expand)  
at cfdelete2ecfm1653432586.runPage(C:\ColdFusion8\wwwroot\orig_gallery\delete.cfm:1) 


coldfusion.tagext.io.FileUtils$CouldNotDeleteFileException: ColdFusion could not delete the file C:\ColdFusion8\wwwroot\orig_gallery\gallery\CTNC ARTHUR R. DEPEW.jpg for an unknown reason.
	at coldfusion.tagext.io.FileUtils.delete(FileUtils.java:128)
	at coldfusion.tagext.io.FileTag.delete(FileTag.java:372)
	at coldfusion.tagext.io.FileTag.doStartTag(FileTag.java:260)
	at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2661)
	at cfdelete2ecfm1653432586.runPage(C:\ColdFusion8\wwwroot\orig_gallery\delete.cfm:1)
	at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)
	at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370)
	at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
	at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279)
	at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
	at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
	at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
	at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
	at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
	at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
	at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
	at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
	at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
	at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
	at coldfusion.CfmServlet.service(CfmServlet.java:175)
	at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
	at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
	at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
	at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
	at jrun.servlet.FilterChain.service(FilterChain.java:101)
	at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
	at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
	at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
	at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
	at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
	at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
	at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
	at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
	at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

 



Thanks for your time!!
Was This Post Helpful? 0
  • +
  • -

#11 garyrgilbert  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 22-July 08

Re: Delete image from image gallery

Posted 05 December 2008 - 08:26 AM

Thanks for posting the stack trace.

I couldn't help but notice that your file names have spaces in them. Typically file names with spaces in them are illegal in Java and or need to be escaped.

I would suggest that you check your file name for spaces and other illegal characters before saving it to the file system, this will also make your code portable. Normally what I do is create a uuid as my filename and save the user defined name and my uuid in the database, thereafter I always use the uuid as the primary key for the table in the database.

You can use the replace function

Replace(filename,' ' , '_', 'ALL') or use the UUID method which will solve all your problems including uploading files with the same name.
Was This Post Helpful? 0
  • +
  • -

#12 ila_fadila  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 01-January 09

Re: Delete image from image gallery

Posted 01 January 2009 - 08:25 PM

hye.. I do have exactly the same error.. and still failed.

Quote

midasxl @ 5 Dec, 2008 - 05:21 AM
Another thing I've noticed is that it works at random times. I will upload an image and then successfully delete it. Then I will upload another image and successfully delete that one as well. On the third go around it will kick back an error telling me it cannot delete for an unknown reason.

I noticed that its happend whenever I tried to delete an image files that I transfered to my PC from my sony handphone.this kind of image will have properties or attributes date picture taken and the camera model of handphone. is this why the error occurd?i have no ideas why this happend.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1