【问题标题】:No uploaded photo display in Mac browsers?Mac 浏览器中没有上传的照片显示?
【发布时间】:2011-02-25 21:35:15
【问题描述】:

我对此完全感到困惑...使用 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 浏览器。 IE、Chrome、FF、Windows 上的 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>

【问题讨论】:

  • 您是否尝试过其他浏览器?比如Safari,mac的原生?
  • 再一次,在Windows环境下添加相同代码的firebug,谢谢
  • 是的 - Mac 中没有浏览器可以工作。在 Safari、Chrome、Opera 和 IE 中尝试过。我在顶部发布了 Windows FB 代码 - 几乎就像 JS 由于某种原因无法在 Mac 环境中工作一样?

标签: javascript jquery asynchronous upload photo


【解决方案1】:

如文档所示:

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. 
}

“类型”变量由操作系统/浏览器实现。

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

How can I get file extensions with JavaScript?

【讨论】:

  • Gotcha - 我觉得这是正确的路径......但是该功能将文件名正确写入数据库(根据我们的开发人员),因此文件在输出中显示正常。这是步骤过程,仅供参考: 1. 上传图片 2. 填写信息 3. 上传的图片在顶部输出 PDF。如果文件正确进入数据库,是否还需要强制 Mac 文件类型?
  • 如果您正在从 DB 输出并且文件正确写入 DB,则您不必仍然解析扩展名。在其他情况下,您应该这样做。
猜你喜欢
  • 2021-07-04
  • 2020-02-27
  • 1970-01-01
  • 1970-01-01
  • 2015-05-08
  • 2016-07-29
  • 2022-11-11
  • 2011-01-24
  • 2014-09-28
相关资源
最近更新 更多