Export to GitHub

php-for-android - issue #11

Unable to create file 0 because Read-only file


Posted on Mar 4, 2012 by Helpful Cat

What steps will reproduce the problem? 1. I cant save files to /sdcard/ 2. I cant user fopen, because of permissions 3. Unable to create file 0 because Read-only file

What is the expected output? What do you see instead? FIX ME! implement getprotobyname() bionic/libc/bionic/stubs.c:450 FIX ME! implement getprotobyname() bionic/libc/bionic/stubs.c:450
Warning: touch(): Unable to create file 0 because Read-only file system in /mnt/sdcard/www/test.php on line 51 Warning: chmod(): No such file or directory in /mnt/sdcard/www/test.php on line 52
Warning: fopen(0): failed to open stream: Read-only file system in /mnt/sdcard/www/test.php on line 53 can't open file

What version of the product are you using? On what operating system? http://android-scripting.googlecode.com/files/sl4a_r3.apk http://php-for-android.googlecode.com/files/phpforandroid_r1.apk

Please provide any additional information below.

I used php script:

protected function download($link) {
    $json = file_get_contents($link);
    $result = json_decode($json);

/* json result {"status":"ok","name":"mama","link":"http://www.darxx.com/pixelart.png"} */ if (!empty($result->status)) {

        $myFile = "'/sdcard/www/file/" + $result->name;
        if (!file_exists($myFile)) {
            touch($myFile);
            chmod($myFile, 0777);
             $fh = fopen($myFile, 'w') or die("can't open file");
            $stringData = file_get_contents($result->link);
            fwrite($fh, $stringData);
            fclose($fh);
        }

        $this->dialog('Information', 'Download ' + $result->name + ' file done');
    }
    else {
        $this->dialog('Connection failed..', 'opa');
    }
}

How i can save files from web to my sdcard?

Comment #1

Posted on Mar 4, 2012 by Helpful Cat

On what operating system? Android 4.0.3 Samsung Galaxy S2

Status: New

Labels:
Type-Defect Priority-Medium