I am a newbie, obviously I am here, and I have reviewed most (if not all) of the issues for uploading images/files to a server but I have a different perspective.

I am working on a script for people to use there WebTV to upload images/files to a remote server. Thus the issue is they are basically the "admin" (no?) that tells one server to upload an image, for example, from another server. It must be done in the fashion since webTV (msnTV) has to hd or caching capabilities.

I am wondering if this is some sort of FTP protocol with remote handling? But I will assign a user with a destination folder. I am using WinXP (for now, Linux/apache are just a bit around the corner) with Sambar Server, PHP 4.2.3.

I have reviewed the FOPEN scripts with FWRITE and all indications are that the file is being read where the file being read address is a URL (http://server.com/image.gif) and the destination being what? Should I be using a Windows addrss such as c:/server_path/doc_dir/vhost/user/files/..... ?

I know that this is very easy for the advanced and experienced but I get a bit lost in the correct methods of even approaching this project.

The typical <input type="file" name=" ...... > will NOT work with the webTV user since they have no stored files.

There is a great example at: http://www.transloader.com/tl.cgi where it clearly is an FTP method. I run an FTP server and can EASILY assign a user with a directory so the issue is how to tell PHP on my server to upload THAT image/file to that location.

Thank you so much for your help.

Sincerely.... majoy newbie

    Maybe this will help... these are NOT complete programs (just snippets of some in my library), but hopefully will point you in the right direction..

    <?php
      // PHP Remote File Download Program
      function file_get_contents($filename)
      {
        $fp = @fopen($filename, "r");
        if (!($fp))
        {
          return 0;
        }
        while (!feof($fp))
        {
          $temp .= fread($fp, 4096);
        }
        return $temp;
      }
    
      if ($remote_file=="")
      {
        ?>
    <HTML>
    <HEAD>
    <TITLE>
    PHP Remote File Grabber
    </TITLE>
    </HEAD>
    <BODY>
    This is a very simple program that takes a file from a remote server and saves it to the host machine.  
    If you don't know what the heck this is, don't mess with it!<BR><BR> <FORM ACTION="<?php echo $php_self?>" METHOD=POST> Remote File To Grab: <INPUT TYPE=TEXT SIZE=40 NAME=remote_file><br> Save To Local File: <INPUT TYPE=TEXT SIZE=40 NAME=local_file><BR> <INPUT TYPE=SUBMIT VALUE="Grab It!"> </FORM> </BODY> </HTML> <?php } else { $data=file_get_contents("$remote_file"); $fp=fopen("$local_file","wb"); fputs($fp,$data,strlen($data)); fclose($fp); ?> <HTML> <HEAD> <TITLE> PHP Remote File Grabber </TITLE> </HEAD> <BODY> Looks like we took<BR><BR> <B><?php echo $remote_file?></B><BR><BR> and saved it to<BR><BR> <B><?php echo $local_file?>!!</B> <BR><BR> Care to grab another?<BR> <FORM ACTION="<?php echo $php_self?>" METHOD=POST> Remote File To Grab: <INPUT TYPE=TEXT SIZE=40 NAME=remote_file><br> Save To Local File: <INPUT TYPE=TEXT SIZE=40 NAME=local_file><BR> <INPUT TYPE=SUBMIT VALUE="Grab It!"> </FORM> </BODY> </HTML> <?php $remote_file=""; $local_file=""; } ?>

    Ok.. I lied.. that is a complete program.. One I wrote because I didn't want to download a 50+MB file on my dial-up connection then have to upload it to my server. In stead, this downloads it directly to my server when I run the script..

    Anyhow, it's not the most efficient coding I've done (far from it!), but it should at very least point you in the right direction.

      🙂

      Thank you for this script, this not only works, it is a great learning tool for me. It is very interesting to me the way you constructed it. I now must learn how to include error control, over-writing a file protection, and banning specified extenstions from being uploaded.

      Again, thank you so much for this lesson.

      ... Brian

      🙂

        Write a Reply...