mostafamemariani / php-for-android

Automatically exported from code.google.com/p/php-for-android
0 stars 0 forks source link

Unable to create file 0 because Read-only file #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I can`t save files to /sdcard/ 
2. I can`t 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?

Original issue reported on code.google.com by Dar...@gmail.com on 4 Mar 2012 at 11:44

GoogleCodeExporter commented 8 years ago
On what operating system?
Android 4.0.3 Samsung Galaxy S2

Original comment by Dar...@gmail.com on 4 Mar 2012 at 11:47