Answered
Getting file extension from cfhttp transfer.
Hi,
I run a file hosting website built in Coldfusion. The server runs Coldfusion MX 6.1 and IIS/6.0 on Windows Server 2003 Standard edition.
At the moment, i'm using just a standard upload form and the <cffile action="upload"> tag for users to upload files.
I'd like to implement a feature on my site where users have the option to get files directly from another website by entering the url and have it transferred to my site to be hosted, kind of like imageshack does.
To do this, I'm using the cfhttp tag to get the file from the url and have it saved to a location on my server. the code i'm using at the moment is like this:
<cfhttp url="#form.url#" getAsBinary="yes" path="C:\Inetpub\wwwroot\files\"></cfhttp>
This basically works fine in that the file is transferred from the site and stored on my server ok, but there are a few more things I need to be able to accomplish.
1. I need to be able to make the file name unique, like the <cffile nameconflict="makeunique"> option, so it doesn't have a problem with duplicate file names.
2. I need to be able to limit the file extensions and file size that the users can host, for example only jpg, bmp, png files and no bigger than 1.5mb
3. I need to be able to get the file name as a variable so I can output the path to the file for the user .
I'd be grateful if someone could help me with this.
Thanks in advance.
I run a file hosting website built in Coldfusion. The server runs Coldfusion MX 6.1 and IIS/6.0 on Windows Server 2003 Standard edition.
At the moment, i'm using just a standard upload form and the <cffile action="upload"> tag for users to upload files.
I'd like to implement a feature on my site where users have the option to get files directly from another website by entering the url and have it transferred to my site to be hosted, kind of like imageshack does.
To do this, I'm using the cfhttp tag to get the file from the url and have it saved to a location on my server. the code i'm using at the moment is like this:
<cfhttp url="#form.url#" getAsBinary="yes" path="C:\Inetpub\wwwroot\files\"></cfhttp>
This basically works fine in that the file is transferred from the site and stored on my server ok, but there are a few more things I need to be able to accomplish.
1. I need to be able to make the file name unique, like the <cffile nameconflict="makeunique"> option, so it doesn't have a problem with duplicate file names.
2. I need to be able to limit the file extensions and file size that the users can host, for example only jpg, bmp, png files and no bigger than 1.5mb
3. I need to be able to get the file name as a variable so I can output the path to the file for the user .
I'd be grateful if someone could help me with this.
Thanks in advance.
