uploading files without a form

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

can anyone point me to some straightforward information on
file uploading without using an html form? That is, direcly from
within a php script.

if I know the local path etc. to a particular requested file how can I send
directly to a location on a remote webserver following
a request from the remote server?

The motivation is that I have a large number of image files that are
infrequently requested
but need to be available  in full-weight format (2meg+ size) as and when
required from a website.
I don't really want to store the full size fles online as it would be quite
a few gigabytes, just a preview size.
is all that's needed. Local storage is very inexpensive and easier to

When a file is requested, I simply want the webserver to call my local
and get it to upload the requested file (or files ) to the webserver to be
picked up by the user.

 cant seem to get a handle on this - all the info on uploading
seems to be about uploading from a form. Any pointers would be appreciated.

Re: uploading files without a form

Chamomile wrote:
Quoted text here. Click to load it

Sure.  Let's say your local server is called local.com and your
remote server is remote.com.  Then remote.com can simply copy
your local files for temporary storage:

copy('http://local.com/localpath/locaimage.ipg ',

Obviously, you will need to run a preiodic cleanup on the
remote server...

Quoted text here. Click to load it

You don't need uploading.  Simple copying would suffice.


Re: uploading files without a form

Quoted text here. Click to load it

Thanks for that - I'll give it a go!
As the Great Lord Buckley said:
'It was so simple, it eluded me...'

Re: uploading files without a form

Quoted text here. Click to load it

spoke too soon.
couldnt get it to work - error message:

'failed to open stream: HTTP wrapper does not support writeable connections.

when I check the php info the 'allow_url_fopen' is set to 'on' ...on the
remote server (with the script running there)
on my local server the allow_url_fopen is set to 'on' but appears as 1 in
(i've tried running the copy() function locally and on the remote server -
in fact i am now so confused i dont know where it should be run)

if i run copy() locally i can copy a file around the pc anywhere i like, but
as soon as i use a web url it fails.
i think maybe the local version of php is too old (unsupported use of urls
in copy()?) so I try to
upgrade local php (4.2.2)  to 4.3.1 which is what my web host server runs.
can i do that? no.
a whole day wasted trying to upgrade php on the off-chance that's the
i've posted an sos on that now!

Re: uploading files without a form

Chamomile wrote:
Quoted text here. Click to load it

The copy command should run on the webserver. Use a URL to access the local
file and a file system path name to reference the target of the copy. If you
are still getting an error message, post the code you actually used for the
copy. We can only guess at what system the code is on and what values you've
used for the copy command.


Re: uploading files without a form

*** Chamomile escribió/wrote (Sun, 6 Mar 2005 17:18:54 +0000 (UTC)):
Quoted text here. Click to load it

I think your function is readfile(). Manual says: "You can use a URL as a
filename with this function if the fopen wrappers have been enabled."

-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Manda tus dudas al grupo, no a mi buzón
-+ Send your questions to the group, not to my mailbox

Re: uploading files without a form

Quoted text here. Click to load it

yabut, I don't he needs even that.  Cant you simply link to your local file?
(also, you wont be getting charged against your monthly hosting bandwidth)
<a href="http://your.ip.if.its.static/dir/file.ext ">click here</a>
you do, of course need to be running a web server or ftp server on your
local box.

you can even make the file list links dynamically if you're running php on
your local server by including a file.php that is on your local server which
lists out the files.
include "http://your.ip.if.its.static/lister.php ";  your local server will
run this locally.  see
http://groups-beta.google.com/group/comp.lang.php/browse_frm/thread/b78e1fdefd5c4bb3/86cd7e036de7d5ed?q=remote +group:alt.php+author:juglesh#86cd7e036de7d5ed


Site Timeline