0

http://fineuploader.com/ を Coldfusion サーバー側で使用しようとすると、500 Internal Server Error が発生しますhttps://github.com/Widen/fine-uploader-server/tree/master/coldfusion

コンソールは言う:
[FineUploader] xhr 応答テキストを解析しようとするとエラーが発生します (SyntaxError: Unexpected token <) at this line in window.console.log('<' + level + '> ' + message);

Server CFC の応答メッセージから来ているようです。

<!--- Code provided by Pegasus Web Productions LLC - www.pegweb.com --->
<!--- get stuck use the forums http://github.com/Widen/fine-uploader --->
<!--- Tested with Adobe CF Enterprise 9.x and Fine Uploader --->
<CFCOMPONENT HINT="I do your uploads from Fine Uploader" >
<!--- function for single file submission uploads where XHR is not supported ex:->
<CFFUNCTION NAME="Upload" ACCESS="remote" OUTPUT="false" RETURNTYPE="any"     RETURNFORMAT="JSON" >
    <CFARGUMENT NAME="qqfile" TYPE="string" REQUIRED="true" />

    <CFSET var local = structNew() >
    <CFSET local.response = structNew() >
    <CFSET local.requestData = GetHttpRequestData() ><!--- get the request headers   and body --->
    <CFSET UploadDir = "/Test/file2" ><!--- set your upload directory here ex: c:\website\www\images\ --->
    <!--- check if XHR data exists --->
    <CFIF len(local.requestData.content) GT 0 >

        <CFSET local.response = UploadFileXhr(arguments.qqfile, local.requestData.content) >

        <CFELSE><!--- no XHR data so process this as standard form submission --->
            <!--- upload the file --->
            <CFFILE ACTION="upload" FILEFIELD="form.qqfile" DESTINATION="#UploadDir#" NAMECONFLICT="makeunique" >

            <!--- populate our structure with information about the image we just uploaded in case we want to use this later for CFIMAGE tags or any other processing --->
            <CFSET local.metaData = { clientFile=FILE.clientFile, clientFileExt=FILE.clientFileExt, clientFileName=FILE.clientFileName, contentSubType=FILE.contentSubType, contentType=FILE.contentType, fileSize=FILE.fileSize } />
            <!--- return the response --->
            <CFSET local.response['success'] = true >
            <CFSET local.response['type'] = 'form' >
    </CFIF>
    <CFRETURN local.response >
</CFFUNCTION>

<!--- function for browsers that support XHR ex: Almost anything but IE --->

<CFFUNCTION NAME="UploadFileXhr" ACCESS="private" OUTPUT="false" RETURNTYPE="struct" >
    <CFARGUMENT NAME="qqfile" TYPE="string" REQUIRED="true" />
    <CFARGUMENT NAME="content" TYPE="any" REQUIRED="true" />

    <CFSET var local = structNew() >
    <CFSET local.response = structNew() >
    <CFSET UploadDir = "" ><!--- set your upload directory here ex: c:\website\www\images\ --->
    <!--- write the contents of the http request to a file. The filename is passed with the qqfile variable --->
    <CFFILE ACTION="write" FILE="#UploadDir#\#arguments.qqfile#" OUTPUT="#arguments.content#" NAMECONFLICT="makeunique" >

    <!--- populate our structure with information about the image we just uploaded in case we want to use this later for CFIMAGE tags or any other processing --->
    <CFSET local.metaData = { clientFile=FILE.clientFile, clientFileExt=FILE.clientFileExt, clientFileName=FILE.clientFileName, contentSubType=FILE.contentSubType, contentType=FILE.contentType, fileSize=FILE.fileSize } />

    <!--- return custom JSON if desired--->
    <CFSET local.response['success'] = true >
    <CFSET local.response['type'] = 'xhr' >
    <CFRETURN local.response >
</CFFUNCTION>

呼び出しページ

    <div id="thumbnail-fine-uploader">
    </div>
    <script src="/js/jQueryv1.9.1.js">
    </script>
    <script src="/Test/file2/jquery.fineuploader-3.4.1.js">
    </script>
    <script>
        $(document).ready(function(){
            var thumbnailuploader = new qq.FineUploader({
                element: $('#thumbnail-fine-uploader')[0],
                request: {
                    endpoint: 'image-uploader.cfc?method=Upload'
                },
                multiple: false,
                validation: {
                    allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
                    sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
                },
                callbacks: {
                    onComplete: function(id, fileName, responseJSON){
                        if (responseJSON.success) {
                            $('#thumbnail-fine-uploader').append('<img src="img/success.jpg" alt="' + fileName + '">');
                        }
                    }
                }
            });
        });
    </script>
4

1 に答える 1