从ios phonegap中的url下载图像

时间:2013-07-02 04:00:44

标签: iphone ios cordova-2.0.0

我正在尝试从网址下载图片并且在ios中没有成功,但在android中它已成功完成。

var url = "http://www.intelligrape.com/images/logo.png"; // image url
try{
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {
        var imagePath = fs.root.fullPath + "/logo.png"; // full file path
        var fileTransfer = new FileTransfer();
        fileTransfer.download(url, imagePath, function (entry) {
            alert(entry.fullPath); // entry is fileEntry object
        }, function (error) {
            alert("Some error");
        });
    })
 }catch(e){
    alert(e);
 }

我收到错误LocalFileSystem未定义。我包括cordova2.5.0.js。

我的Config.xml在下面。

<?xml version="1.0" encoding="UTF-8"?>
<cordova>
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="UIWebViewBounce" value="true" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="EnableLocation" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="OpenAllWhitelistURLsInWebView" value="false" />
<preference name="BackupWebStorage" value="cloud" />

<plugins>
    <plugin name="Device" value="CDVDevice" />
    <plugin name="Logger" value="CDVLogger" />
    <plugin name="Compass" value="CDVLocation" />
    <plugin name="Accelerometer" value="CDVAccelerometer" />
    <plugin name="Camera" value="CDVCamera" />
    <plugin name="NetworkStatus" value="CDVConnection" />
    <plugin name="Contacts" value="CDVContacts" />
    <plugin name="Debug Console" value="CDVDebugConsole" />
    <plugin name="Echo" value="CDVEcho" />
    <plugin name="File" value="CDVFile" />
    <plugin name="FileTransfer" value="CDVFileTransfer" />
    <plugin name="Geolocation" value="CDVLocation" />
    <plugin name="Notification" value="CDVNotification" />
    <plugin name="Media" value="CDVSound" />
    <plugin name="Capture" value="CDVCapture" />
    <plugin name="SplashScreen" value="CDVSplashScreen" />
    <plugin name="Battery" value="CDVBattery" />
    <plugin name="Globalization" value="CDVGlobalization" />
     <plugin name="InAppBrowser" value="CDVInAppBrowser" />
   </plugins>

   <access origin="*" />
</cordova>

1 个答案:

答案 0 :(得分:0)

包括所有自定义js文件之前的cordova2.5.0.js文件。你可能会在你的代码之后加入它