How to check a file's existence in phone directory with phonegap

后端 未结 14 2015
太阳男子
太阳男子 2020-12-05 10:49

I\'m writing an Android application with Phonegap 1.4.1 and Sencha that downloads and reads pdf files. How can I check whether the file exists in the phone directory using e

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 11:48

    Darkaico, Kurt and thomas answers didn't work for me. Here's what worked for me.

    $.ajax({
    url:'file///sdcard/myfile.txt',
    type:'HEAD',
    error: function()
    {
        //file not exists
    alert('file does not exist');
    },
    success: function()
    {
        //file exists
    alert('the file is here');
    }
    });
    

提交回复
热议问题