Mac浏览器中没有上传的照片显示?

时间:2011-02-25 21:35:15

标签: javascript jquery asynchronous upload photo

我对此感到非常难过......使用asyncUpload和swfUpload JS插件让用户上传照片。上传后,照片会显示在一个小区域内。适用于任何Windows浏览器,但不适用于任何Mac浏览器。太奇怪了。我把它缩小到这篇文章:

            // Called when upload completed successfully (puts success details into hidden fields)
            upload_success_handler: function (file, response) {
                $("input[name$=_filename]", container).val(file.name);
                $("input[name$=_guid]", container).val(response);
                $("span[id$=_completedMessage]", container).html("<img class='uploader' src='/public/assets/logos/{0}{1}' /><br />"
                            .replace("{0}", response)
                            .replace("{1}", file.type)
                        );
            },

以下是Firebug所说的在Mac浏览器中生成的内容(特别是FF 3.6.13):

<span id="photo_completedMessage" style="display: inline;">
<img class="uploader" width="0" height="0" src="/public/logos/66764b72-ad65-44b3-8c08-e74c24ee1356JPEG">
<br>
</span>

所以正在生成GUID,它有点找到文件类型?但是不要将它作为扩展或其他东西?如果我在Bug中手动输入它,它显示正常,所以它在服务器上找到图像。我迷路了。帮助赞赏。同样,这仅适用于任何Mac浏览器。 Windows上的IE,Chrome,FF,Safari都可以正常工作。

编辑 - 这是Windows Firebug代码:

<span id="photo_completedMessage" style="display: inline;">
<img class="uploader" width="203" height="285" src="/public/logos/66764b72-ad65-44b3-8c08-e74c24ee1356.jpg">
<br>
</span>

1 个答案:

答案 0 :(得分:0)

正如文档中所示:

http://demo.swfupload.org/Documentation/

File Object
The file object is passed to several event handlers.
It contains information about the file.
Some operating systems do not fill in all the values
(this is especially true for the createdate and modificationdate values).

{
id : string,            // SWFUpload file id, used for starting or cancelling and upload
index : number,         // The index of this file for use in getFile(i)
name : string,          // The file name. The path is not included.
size : number,          // The file size in bytes
type : string,          // The file type as reported by the client operating system
creationdate : Date,        // The date the file was created
modificationdate : Date,    // The date the file was last modified
filestatus : number,        // The file's current status. Use SWFUpload.FILE_STATUS to interpret the value. 
}

'type'变量由操作系统/浏览器实现。

也许您应该解析“file.name”并搜索其扩展名。

How can I get file extensions with JavaScript?