uploading files without a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chamomile

    uploading files without a form

    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.













  • Alvaro G. Vicario

    #2
    Re: uploading files without a form

    *** Chamomile escribió/wrote (Sun, 6 Mar 2005 17:18:54 +0000 (UTC)):[color=blue]
    > 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.[/color]

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

    Comment

    • juglesh

      #3
      Re: uploading files without a form


      "Alvaro G. Vicario" <kAlvaroNOSPAMT HANKS@terra.es> wrote in message
      news:1m5xklgnsf bbd$.1n3vh95hkm i9o.dlg@40tude. net...[color=blue]
      > *** Chamomile escribió/wrote (Sun, 6 Mar 2005 17:18:54 +0000 (UTC)):[color=green]
      >> 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.[/color]
      >
      > 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."[/color]

      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:passwo rd@your.ip.if.i ts.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


      Comment

      • NC

        #4
        Re: uploading files without a form

        Chamomile wrote:[color=blue]
        >
        > can anyone point me to some straightforward information on
        > file uploading without using an html form? That is, direcly from
        > within a php script.[/color]

        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...
        [color=blue]
        > cant seem to get a handle on this - all the info on uploading
        > seems to be about uploading from a form.[/color]

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

        Cheers,
        NC

        Comment

        • Chamomile

          #5
          Re: uploading files without a form


          ">[color=blue]
          > You don't need uploading. Simple copying would suffice.
          >
          > Cheers,
          > NC
          >[/color]

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


          Comment

          • Chamomile

            #6
            Re: uploading files without a form

            > > You don't need uploading. Simple copying would suffice.[color=blue][color=green]
            > >
            > > Cheers,[/color]
            > Thanks for that - I'll give it a go![/color]


            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_fope n' 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




            Comment

            • Virgil Green

              #7
              Re: uploading files without a form

              Chamomile wrote:[color=blue][color=green][color=darkred]
              >>> You don't need uploading. Simple copying would suffice.
              >>>
              >>> Cheers,[/color]
              >> Thanks for that - I'll give it a go![/color]
              >
              >
              > 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_fope n' 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[/color]

              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


              Comment

              Working...