Announcement

Collapse
No announcement yet.

Question about image upload

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

  • Question about image upload

    Well the problem is the fopen($source,"w"); the script below gives the following error: 'File/directory does not exist' while the file really exists, the $source is something like: C:\dir\dir\file.jpg...why doesn't this work? I did simulate the page below please help me to find the problem.

    The site runs doesn't support php_functions yet.
    Let's assume the file is named temp.php3

    I made a form like this:

    echo "<form method=post action='temp.php3' enctype='multipart/form-data'>";
    echo "<input type=file name=file>";
    echo "<input type=submit value='Preview'>
    echo "</form>";

    Then I want the picture preview

    $file=stripslashes($file); //Please note Magic Quotes is set ON
    echo "<img src='$file' alt='Stupid Picture'>";
    echo "<form method=post action='temp.php3'>";
    echo "<input type=hidden name=file value='$file'";
    echo "<input type=submit value='Upload'>
    echo "<form>";

    Now i want to upload it:

    $file=stripslashes($file); //Please note Magic Quotes is set ON
    $source = fopen($file,"r");
    if ($file_type == "image/pjpeg")
    $type="jpg";
    elseif ($file_type == "image/gif")
    $type="gif";
    elseif ($file_type == "image/bmp")
    $type="bmp";
    else
    exit;
    $dest = fopen("ftp://user[email protected]/html/archive/screenshots/picture.$type","w");
    while ($contents = fread($source,4096)) {
    fwrite($dest, $contents, strlen($contents) );
    }
    fclose($source);
    fclose($dest);

    Please help me, really thanks already

    [Edited by MeltX on 01-04-2001 at 11:49 AM]

  • #2
    http://www.weberdev.com/ViewArticle.php3?ArticleID=62
    Site: -http://www.jazz2online.com-
    Forums -http://www.jazz2online.com/jcf/-

    Comment


    • #3
      Thanks but you can't upload a file to an ftp with the copy() function, it had to be done with the fopen() fclose() and fwrite() function.

      Comment


      • #4
        I know..but those are just basic pointers for how to do it.. I don't have the time to write/research..sorry.
        Site: -http://www.jazz2online.com-
        Forums -http://www.jazz2online.com/jcf/-

        Comment


        • #5
          Thanks anyway

          By the way but I already did it myself o_O

          Comment

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