There are two ways to do this. The idea I posted for GoogleFileUpload
was very generic, and actually kind of wrong.
If you just want to post forms in GAE that upload to a different
server, use:
<form name="upForm" action="not.gae/uploadScript.php?x=..."
target="noreload" enctype="multipart/form-data" method="post">
<input type="file" size="30" name="upload"></input>
<input name="Submit" onclick="return upload();" value="upload"
type="submit"></input>
</form>
This is a form that targets a different server, and posts all the
inputs, including the file field, to your upload script. You could
make this upload script a servlet, and basically copy+paste the
GoogleFiles implementation, but ditch all the appengine stuff and just
use regular java.io.File routines in the servlet...
...But java hosting costs money, and php is cheaper and often better
hosting {except GAE, which is FREE and Java and on the Google Cloud}.
So, here's a quick rundown of what your php has to do:
<?php
$upload = $_FILES['upload']; //The text 'upload' is the name of the
file input in the form
$uploadfile= $upload['tmp_name'];//This is a temporary file from the
upload, in /tmp
$uploadname=$upload['name'];//The user's original name. You don't
NEED this
$srcfile = fopen($uploadname,'r');//Open the temp file for reading
$data = fread($srcfile,filesize($uploadname));//Put data into memory
fclose($srcfile);//Close the file
//Next, open a file stream for output, make sure it's in your server's
web folder
$dstfile = fopen('/home/your/account/dir/public_html/'.
$uploadname,'w');//Get OR make
fwrite($dstfile,$data);//Put data in file
fclose($dstfile);//Close file
echo 'File upload successful!';
?>
When done, this will put an upload 'sweetPic.jpg' into 'http://
your.site/sweetPic.jpg'...
Just beware, php sometimes limits file upload size.
Should you decide to access this data later in GAE, you can use
URLFetch to get it off your server.
For some real trickery, instead of echo 'File upload successful', try:
echo '<html><head/><body><script>window.location='your-gae-
site.appspot.com/postUploadServlet?name=$uploadname';</script>';
This will redirect back to GAE, where you can display your external
files, like images with <img src="other.site/sweetPic.jpg" />, or
<iframe src="other.site/fileName.ext" />... The filename used should
be sent back to GAE using a parameter so the php can tell it what
filename it used to save with.
There's a LOT of details and overhead you SHOULD deal with to
implement something like this {like restricting uploads to requests
that are referred from you GAE site}, but I think this should be
enough to help you along.
PS - Basic Imagery widget w/ scaling, cropping and fading is almost
done... I might make a google code project from it, provided I get the
blessing of T Y Tung... And maybe with a little gwt flavour as
well...
On Jun 25, 2:26 am, Hyllier Leunam <
hyll...@gmail.com> wrote:
> Hi, Alyxandor, what you just said is what I need... I need to store
> the files into my own server but using an app engine web interface for
> the upload form, I think that this can be done with some java code...
> But I need help, please teach me how to solve my problem... my mail is
>
hyll...@gmail.com
>
> 2009/6/25, Alyxandor <
a.revolution.ultra.b...@gmail.com>: