problem with upload..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kujtim
    New Member
    • Sep 2007
    • 11

    problem with upload..

    i got html code
    file name
    [HTML]html
    <html>

    <head>
    <title></title>
    </head>

    <body>
    <form enctype="multip art/form-data" action="upload. php" method="POST">
    Please choose a file: <input name="uploaded" type="file" /><br />
    <input type="submit" value="Upload" />
    </form>
    </body>

    </html>
    [/HTML]
    and my php file name upload.php
    [CODE=php]
    <?php

    $target = "http://example.com/up/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1;

    //This is our size condition
    if ($uploaded_size > 350000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }

    //This is our limit file type condition
    if ($uploaded_type =="text/php")
    {
    echo "No PHP files<br>";
    $ok=0;
    }

    //Here we check that $ok was not set to 0 by an error
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    }

    //If everything is ok we try to upload it
    else
    {
    if(move_uploade d_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ".
    basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?>

    [/CODE]
    <link removed> is place where i want to upload file
    <link removed> is place where my script is located
    and when run the script i am reciving thiss

    Code:
    Warning: move_uploaded_file([url]http://example.com/up/l1.php[/url]) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
    
    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpAKTFWT' to 'http://example.com/up/l1.php' in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
    Sorry, there was a problem uploading your file.?>
    please help
    Last edited by Atli; Oct 20 '07, 01:30 AM. Reason: Changed [code] tags to [code=php] tags and removed links.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I have removed the links from your post. Please refrain from using real URL's in your posts.

    As to your problem.
    Try using a relative path to the your $target file instead of an absolute path.
    Instead of using "http://example.com/up/" use "up/".

    Comment

    • kujtim
      New Member
      • Sep 2007
      • 11

      #3
      thenks for your advise about url's .

      i have tryed to to use the relativ url but steal not working . i am reciving the same warning as before

      Code:
       Warning: move_uploaded_file(New Text Document.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
      
      Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpvbACgU' to 'New Text Document.txt' in /is/htdocs/wp1055726_DP59DMU8M7/www/upload.php on line 37
      Sorry, there was a problem uploading your file.?>
      thenks for helping
      Last edited by Atli; Oct 23 '07, 12:20 AM. Reason: Added [code] tags.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi. Sorry for the late reply.

        Take a closer look at the second batch of errors. That is not the same error as before :)

        This error would suggest that you (the user that is running your http server) does not have permission to write in the directory you are trying to save the files in.

        The PHP code works fine (most likely). The problem is that you server won't allow it to write into that particular directory.

        The best way to make sure your PHP code can write to a directory is that have a PHP code create it. Check out the mkdir() function.

        Comment

        Working...