?
Solved

Trouble with file upload

Posted on 2010-01-13
9
Medium Priority
?
260 Views
Last Modified: 2013-12-24
I have some code to upload an image to a server, and the problem is that the file is uploaded to the server with no extension, and then I can't read it from the server to move/rename it. Is it not possible to force/specify the file name by doing something like this?

   <cffile action="upload"
   filefield="imagelink"
   destination="#MediaPath#/#photoname#.jpg"
   nameconflict="makeunique"
   file="#photoname#.jpg"
  >

Why won't this work?  I've pulled "working" code from other sites and I'm still having this issue. I can see the file written to the server so I have access.
0
Comment
Question by:nonesuch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 600 total points
ID: 26303969
remove file="#photoname#.jpg" from your code and it should work (i.e. force the the file to be saved with the filename you specify).

are you sure about not being able to access an uploaded file without extension? i do not recall that being a problem... what's your code for moving/renaming the uploaded file? you are using #cffile.serverfile# to get the uploaded filename, right?

Azadi
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26304839
> i do not recall that being a problem.

Neither do I.  

On a side note, are you confirming the file is an image first (and what type)?  Forcing the file to _always_ be saved as a ".jpg" could lead to some problems down the road. For example: saving a .GIF or Word .DOC as .jpg ....
0
 
LVL 3

Author Comment

by:nonesuch
ID: 26304891
Definitely the file is an image.  I was trying to force it to .jpg just to try to get it to work and upload as an image.  It's interestingly enough saving the file name with the name of the lowest directory path -- i.e., in an example full path destination of /photos/user1/thumbnails, it is saving each copy of the image as "thumbnails1", "thumbnails2", etc. (with no extension).

 I will try out the suggestions and get back to you.  
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
LVL 3

Author Comment

by:nonesuch
ID: 26310584
Okay, so when I try to do this:

   <cffile action="upload"
   filefield="imagelink"
   destination="#MediaPath#/#photoname#.jpg"
   nameconflict="makeunique"
  >
   
   <cfdump var="#cffile#">

-----------------

results in:


struct
ATTEMPTEDSERVERFILE       1263436352.jpg
CLIENTDIRECTORY       200800708mom_0283_med.jpg
CLIENTFILE       200800708mom_0283_med.jpg
CLIENTFILEEXT       jpg
CLIENTFILENAME       200800708mom_0283_med
CONTENTSUBTYPE       jpeg
CONTENTTYPE       image
DATELASTACCESSED       {d '1969-12-31'}
FILEEXISTED       NO
FILESIZE       0
FILEWASAPPENDED       NO
FILEWASOVERWRITTEN       NO
FILEWASRENAMED       NO
FILEWASSAVED       NO
OLDFILESIZE       0
SERVERDIRECTORY       e:\websites\localuser\1\fullsize
SERVERFILE       1263436352.jpg
SERVERFILEEXT       jpg
SERVERFILENAME       1263436352
TIMECREATED       {ts '1969-12-31 19:00:00'}
TIMELASTMODIFIED       {ts '1969-12-31 19:00:00'}

------- and sure enough the image is not stored out on the server

So I modified to the other way I've tried to run it, specifying the folder and not the destination file:

   <cffile action="upload"
   filefield="imagelink"
   destination="#MediaPath#"
   nameconflict="makeunique"
  >
             
   <!--- read the image ---->
   <cfimage name="uploadedImage" source="#cffile.serverdirectory#/#cffile.serverFile#" >
   
----- and a file IS uploaded to the server, "fullsize17" without the extension,
and i get an error on <cfimage>

The e:\websites\localuser\1/fullsize17 image format is not supported on this operating system. Use GetReadableImageFormats() and GetWriteableImageFormats() to see which image formats are supported.
The error occurred on line 55.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 1400 total points
ID: 26310660
> then I can't read it from the server to move/rename it.

I think Azadi asked about this before: what code are you using to try and move/delete the file?  And what happens (full error message, etc)... ?

> and a file IS uploaded to the server, "fullsize17" without the extension

    Can you post the cfdump ?

>> and sure enough the image is not stored out on the server
>> FILEWASSAVED       NO

    Well, at least CFFILE is reporting the correct results (ie not saved)

> and i get an error on <cfimage>

     Yes, cfimage _requires_ a file extension. A work-around is to read it into a variable first. But that
     still doesn't solve the original problem.


0
 
LVL 3

Author Comment

by:nonesuch
ID: 26310707
I'm showing you all the code there is -- <cffile> to upload the file, then a <cfimage> to read the image information.  It didn't show the previous cfdump because the error overrode it. I added a <cfexit> right before the <cfimage> to show you the results now after <cffile> without specifying the image name:


struct
ATTEMPTEDSERVERFILE       fullsize
CLIENTDIRECTORY       mi1.jpg
CLIENTFILE       mi1.jpg
CLIENTFILEEXT       jpg
CLIENTFILENAME       mi1
CONTENTSUBTYPE       jpeg
CONTENTTYPE       image
DATELASTACCESSED       {d '2010-01-13'}
FILEEXISTED       YES
FILESIZE       67977
FILEWASAPPENDED       NO
FILEWASOVERWRITTEN       NO
FILEWASRENAMED       YES
FILEWASSAVED       YES
OLDFILESIZE       67977
SERVERDIRECTORY       e:\websites\localuser\1
SERVERFILE       fullsize18
SERVERFILEEXT       [empty string]
SERVERFILENAME       fullsize18
TIMECREATED       {ts '2010-01-13 22:12:43'}
TIMELASTMODIFIED       {ts '2010-01-13 22:12:43'}
0
 
LVL 3

Author Comment

by:nonesuch
ID: 26310782
hold the presses... I think I just found the culprit, and wow is it stupid.  

I was stripping off some information in the code I sent to mask some site particulars, and the fact is that the server directory really didn't have the "last directory" that I indicated, it didn't exist. So that's why it was erroring out.  Now I'm uploading just fine. Wow, that's a couple of days wasted on not completely confirming my destination directory!  Thanks for the assistance, I will award points for your patience.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26310790
What is the code used to set the value of #MediaPath#
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26310792
@nonesuch,

Good, I was just about to tell you I just tested the code and ... unfortunately, it worked fine for me. So I'm glad you solved it.
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question