最初の Uploadify の例で奇妙な問題が発生しています。問題は、SWF ファイルを からロードしようとしているhttp://localhost:8080/myapp/uploadify/uploadify.swf
のに、ファイルが にあることですhttp://localhost:8080/myapp/resources/uploadify/uploadify.swf
。
このため、Firebug および Chrome Dev ツールでは、このファイルに対して 404 が返されます。
コードは次のとおりです。
<link type="text/css" rel="stylesheet"
href="<c:url value="/resources/css/myapp.css"/>" />
<link type="text/css" rel="stylesheet"
href="<c:url value="/resources/uploadify/uploadify.css"/>" />
<link type="text/css" rel="stylesheet"
href="<c:url value="/resources/jquery-ui/jquery-ui-1.8.18.custom.css"/>" />
<script type="text/javascript"
src=<c:url value="/resources/uploadify/jquery-1.4.2.min.js" />></script>
<script type="text/javascript"
src=<c:url value="/resources/uploadify/jquery-ui-1.8.22.custom.min.js" />></script>
<script type="text/javascript"
src=<c:url value="/resources/uploadify/swfobject.js" />></script>
<script type="text/javascript"
src=<c:url value="/resources/uploadify/jquery.uploadify.v2.1.4.min.js"/>></script>
<!-- Scripts to display the dialog and to initialize and control the
uploadify component behavior.
-->
<script type="text/javascript">
function submitUpload() {
try {
fileSelectorElement.uploadify('upload');
} catch (e) {
alert("Failed to start document upload." + e);
}
}
function showUploadDialog() {
try {
$('#uploadDialog').dialog({
modal: true,
buttons: {
"Cancel": function() {
$(this).dialog("close");
},
"Upload": function() {
submitUpload();
}
},
minWidth: 450,
closeOnEscape: false,
title: "Upload a document"
});
} catch (e) {
alert("Could not create upload dialog. " + e);
}
}
$(document).ready(function() {
try {
$("#inputFile").uploadify({
'swf': '<c:url value="/resources/uploadify/uploadify.swf" />',
'script' : '<c:url value="/upload"/>',
'scriptData' : {'dealId': dealId, 'agendaId': agendaId},
'buttonImage': '<c:url value="/resources/uploadify/upload-file.png" />',
'cancelImg' : '<c:url value="/resources/uploadify/cancel.png" />',
'folder' : '/uploads',
'height': 31,
'width': 300,
'multi': false,
'method' : 'post',
'auto' : true,
'onUploadError': function(a, b, c, errorObj) {
alert("Not working: " + errorObj);
},
'onComplete' : function(event, ID, fileObj, response, data) {
if(response == 'success')
alert("Successfully uploaded!");
else
alert("Failed");
}
});
} catch (e) {
alert("Cannot initialize uploadify element " + e);
}
showUploadDialog();
});
</script>
<div id="uploadDialog" style="display: none">
<p>Upload a document here:</p>
<input type="file" id="inputFile" name="inputFile"/>
<form:form modelAttribute="uploadbean" method="post"
enctype="multipart/form-data">
</form:form>
</div>
<div id="uploadPitchSuccess" style="display: none;">
<p class="success">File uploaded successfully.</p>
</div>
<div id="uploadPitchError" style="display: none;">
<p class="success">The file could not be uploaded.</p>
</div>
「swf」パラメーターに相対パスと絶対パスの両方を使用しようとしました。動的 (上記のように) およびハードコードされたパスも同様です。どのような値を設定しても、パスは決して変わりません。
swfも入れてみましhttp://localhost:8080/myapp/uploadify/uploadify.swf
たが、それでも404がスローされます。
ここで本当に明白な何かが欠けているに違いないと思います。しかし、それが何であるかを単純に見ることはできません。
ご協力いただきありがとうございます