当我上传名为“äüö.txt”的文件时,ftp-server上的文件名为“-956.txt”。仅当文件名包含特殊字符时才会发生这种情况。我该如何解决这个问题?
HTML码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<script src="jquery-1.10.2.min.js"></script>
<script src="custom.fineuploader-4.0.3.js" type="text/javascript"></script>
<script type="text/template" id="qq-template-manual-noedit">
<div class="qq-uploader-selector qq-uploader">
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span>Drop files here to upload</span>
</div>
<div class="qq-upload-button-selector qq-upload-button">
<div>Upload a file</div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list">
<li>
<div class="qq-progress-bar-container-selector">
<div class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<span class="qq-upload-file-selector qq-upload-file"></span>
<span class="qq-upload-size-selector qq-upload-size"></span>
<a class="qq-upload-cancel-selector qq-upload-cancel" href="#">Cancel</a>
<span class="qq-upload-status-text-selector qq-upload-status-text"></span>
</li>
</ul>
</div>
</script>
<script type="text/javascript">
$(document).ready(function () {
var manualuploader = $("#fine-uploader-fileUploadEmailCampaigns").fineUploader({
autoUpload: false,
multiple: false,
template: "qq-template-manual-noedit",
editFilename: {
enabled: false
},
request: {
endpoint: 'endpoint.php'
},
});
$('#triggerUpload').click(function () {
manualuploader.fineUploader('uploadStoredFiles');
});
})
</script>
<title>Unbenanntes Dokument</title>
<link href="custom.fineuploader-4.0.3.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="fine-uploader-fileUploadEmailCampaigns">
</div>
<div id="triggerUpload" class="btn btn-primary" style="margin-top: 10px;">Upload</div>
</body>
</html>
PHP-代码:
<?php
// Include the upload handler class
require_once "handler.php";
$uploader = new UploadHandler();
// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
$uploader->allowedExtensions = array(); // all files types allowed by default
// Specify max file size in bytes.
$uploader->sizeLimit = 10 * 1024 * 1024; // default is 10 MiB
// Specify the input name set in the javascript.
$uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value bydefault
// If you want to use the chunking/resume feature, specify the folder to temporarily save parts.
$uploader->chunksFolder = "chunks";
$method = $_SERVER["REQUEST_METHOD"];
if ($method == "POST") {
header("Content-Type: text/plain");
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload("files");
// To return a name used for uploaded file you can use the following line.
$result["uploadName"] = $uploader->getUploadName();
echo json_encode($result);
}
else {
header("HTTP/1.0 405 Method Not Allowed");
}
?>
答案 0 :(得分:0)
我的猜测是你用来写出文件的语言环境($ LANG)与你操作系统的语言环境不匹配。例如,要在我的开发环境(OS X,Java 7,IntelliJ)中正确创建名称中包含非英文字符的文件,我需要确保与我的JVM关联的LANG环境变量是“en_US.UTF-8” “,它匹配OS X中设置的$ LANG变量。