By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,688 Members | 1,888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,688 IT Pros & Developers. It's quick & easy.

uploading files without a form

P: n/a
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
it
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
maintain!

When a file is requested, I simply want the webserver to call my local
server
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.





Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
*** Chamomile escribió/wrote (Sun, 6 Mar 2005 17:18:54 +0000 (UTC)):
When a file is requested, I simply want the webserver to call my local
server and get it to upload the requested file (or files ) to the webserver to be
picked up by the user.


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
--
Jul 17 '05 #2

P: n/a

"Alvaro G. Vicario" <kA*****************@terra.es> wrote in message
news:1m******************************@40tude.net.. .
*** Chamomile escribió/wrote (Sun, 6 Mar 2005 17:18:54 +0000 (UTC)):
When a file is requested, I simply want the webserver to call my local
server and get it to upload the requested file (or files ) to the
webserver to be
picked up by the user.


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."


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.
<a href="ftp://username:pa******@your.ip.if.its.static/dir/file.ext">click
here</a>

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/...cd7e036de7d5ed >

--
hth
juglesh
Jul 17 '05 #3

P: n/a
NC
Chamomile wrote:

can anyone point me to some straightforward information on
file uploading without using an html form? That is, direcly from
within a php script.
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',
'/remotepath/remoteimage.jpg');

Obviously, you will need to run a preiodic cleanup on the
remote server...
cant seem to get a handle on this - all the info on uploading
seems to be about uploading from a form.


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

Cheers,
NC

Jul 17 '05 #4

P: n/a

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

Cheers,
NC


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

P: n/a
> > You don't need uploading. Simple copying would suffice.

Cheers,

Thanks for that - I'll give it a go!

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
phpinfo.(not'on')
(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
problem.
i've posted an sos on that now!
yergh


Jul 17 '05 #6

P: n/a
Chamomile wrote:
You don't need uploading. Simple copying would suffice.

Cheers,

Thanks for that - I'll give it a go!

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 phpinfo.(not'on')
(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
problem.
i've posted an sos on that now!
yergh


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.

--
Virgil
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.