You can't write the the local filesystem in App Engine. You need to use 
Cloud Storage. See:

Reading and Writing Files
https://cloud.google.com/appengine/docs/php/googlestorage/#writing_files_from_your_app

On Sunday, April 19, 2015 at 1:37:24 PM UTC-4, Bảo Nguyên wrote:
>
> run guestbook localhost good.
> but upload app engine error can't open file.
> code:
> <html>
> <head><title>My Guestbook</title></head>
> <body>
> <h1>Welcome to My Guestbook</h1>
> <h2>Please write me a little note below</h2>
> <form action="" method="POST">
> <input type="text" name="user" placeholder="Name" />
> <br />
> <textarea cols="40" rows="5" name="note" placeholder="Comments" 
> wrap="virtual"></textarea>
> <br />
> <input type="submit" name="submit" value="Submit" />
> </form>
> <?php
>
> if (isset($_POST['submit'])){
>
> $user = $_POST['user'];
> $note = $_POST['note'];
>
> if(!empty($user) && !empty($note)) {
> $msg = $user . ' : ' . $note;
> //will open a file
> $fp = fopen("notes.txt","a") or die("Can't open file");
> //will write to a file
> fwrite($fp, $msg."\n");
> fclose($fp);
> }
> }
> ?>
>  
> <h2>The entries so far:</h2>
> <?php
> $file = fopen("notes.txt", "r") or exit("Unable to open file!");
> //Output a line of the file until the end is reached
> while(!feof($file))
>   {
>   //will return each line with a break
>   echo fgets($file). '<br />';
>   }
> fclose($file);
> ?> 
> </body>
> </html>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/dd8b898c-5b76-4b36-ac17-1cd8b8cdf026%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to