#CFFILE.serverFile# returns %20 for files with a space

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default #CFFILE.serverFile# returns %20 for files with a space

    I'm trying to upload a file and then display a thumbnail of the item. This
    works fine except when upload files with a space in the name. I get a red x
    letting me know if couldn't find foo%x0bar.jpg. The title of the image is foo
    bar.jpg
    What do I need to remove spaces from Files?

    Thank you,
    Ken

    kbuska525 Guest

  2. Similar Questions and Discussions

    1. #40633 [NEW]: disk_free_space returns a bad result on filesystems with negative free space
      From: adam-phpbugs at adam dot gs Operating system: *BSD (at least) PHP version: 5.2.1 PHP Bug Type: Filesystem function...
    2. How to use CFFILE to rename files
      I tired the following and got error, please help! All I need is appending all the files within FolderA with "Version1_" in front of the file name...
    3. Using CFFILE on compiled CFM files
      I have a CFM template that renames another CFM template using CFFILE. This works fine until I compile the templates using the cfcompile tool....
    4. cffile upload file field returns temporary path
      Hi, I'm attempting to use cffile upload and the FORM file field is being returned as ...
    5. CFFile won't delete files
      I have a list of articles in my knowledgebase some of which are totally web based and others are DOC or PDF files.... The admin is allowed to...
  3. #2

    Default #CFFILE.serverFile# returns %20 for files with a space

    I'm trying to upload a file and then display a thumbnail of the item. This
    works fine except when upload files with a space in the name. I get a red x
    letting me know if couldn't find foo%x0bar.jpg. The title of the image is foo
    bar.jpg
    What do I need to remove spaces from Files?

    Thank you,
    Ken

    kbuska525 Guest

  4. #3

    Default Re: #CFFILE.serverFile# returns %20 for files with aspace

    I don't have CF at hand right now, so I reserve the right to be wrong, but here
    goes:

    Are you sure CFFILE.serverfile really contains the "%20"? Maybe you're just
    seeing it in the browser?

    If the file name has a space, but your browser cannot show it with <img
    src="#CFFILE.serverFile">, you can try to display your images like this: <img
    src="#urlencodedformat(CFFILE.serverFile)#">

    If the case is vice versa, i.e. the CFFILE.serverFile would actually contain
    the "%20" (I doubt it), <img src="#replace(CFFILE.serverFile,"%20","
    ","all")#"> could do the trick.

    But the best practice, in my opinion, is to replace the spaces with
    underscores "_" right after the upload. Use find() to check if there are spaces
    in the file name, and <CFFILE action="rename" ....> after that ,if necessary.

    Furthermore, you findoneof() and replacelist() are very useful functions, if
    you want to check for more special characters, and replace them with something
    else. It's a good habit to check for ? ? ? ? etc. (in case you can't see the
    characters, they were a o u with umlauts, and a with acute) , and change these
    to a o u a accordingly. Just to begin with.

    Fernis Guest

  5. #4

    Default Re: #CFFILE.serverFile# returns %20 for files with aspace

    If I take your filename literally, foo%x0bar.jpg is not a valid name, since x0 is not a valid hex number. Do you mean foo%20bar.jpg?
    jdeline Guest

  6. #5

    Default #CFFILE.serverFile# returns %20 for files with a space

    If the actual file has a space but your code has a "%20 then use:

    URLDecode(FileNameVariable);

    If not, then somewhere upstream during the naming of the file the name is being URL encoded. Use the above code there to fix it.
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139