Announcement

Collapse
No announcement yet.

Uploading files.....

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Uploading files.....

    I am trying to write a small program that will allow users to upload files to my server. I have been able to accomplish this if the file is stored on the user's local system. But I have not been able to get this to work if the file is stored somewhere on the web.

    Does anyone have a code snippet that accomplishes this? I have looked at the php manual, but it doesn't seem to cover this action.

    Thanks

    CDitty


  • #2
    use fopen

    I would use fopen().

    Just pass the arguments to fopen() like so:


    PHP Code:
    $fd fopen ("http://www.cnunited.com/image.jpg""r");
    $contents fread ($fdfilesize ($filename));
    fclose ($fd);

    $fd fopen("http://www.yourpage.com/" "w");
    fwrite($fd,$contents);
    fclose($fd); 
    Hope this helps,

    -Vic

    Comment


    • #3
      Thanks for the code snippet. Forgive my ignorance.

      I tried your example but I get a parse error on the line below.
      PHP Code:
      $fd fopen("http://www.yourpage.com/" "w"); 
      I checked the permissions and the directory is 777.

      Question. When/where does it get the actual filename for writing to disk?

      Thanks again.

      Chris

      Comment


      • #4
        oh sorry

        Aahhh, sorry, just put the name of the file after the yourpage.com/filename.jpg or whatever.

        If that does not work, try using the copy() function.

        The arguments of the copy() function are as so:
        int copy (string source, string dest);

        Therfore:
        PHP Code:

        copy
        ("http://www.page.com/img.jpg","http://www.newpage.com/img.jpg"); 
        Hope this helps and sorry about the mix up.

        -Vic

        Comment


        • #5
          Re: oh sorry

          Originally posted by krs-one
          [B]Aahhh, sorry, just put the name of the file after the yourpage.com/filename.jpg or whatever.
          Tried this. Didn't work.

          Tried the copy function to. Wouldn't work.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X