SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2005
    0 Post(s)
    0 Thread(s)

    Strange error when using copy function


    I am now up to chapter 10 on "Build your own website using PHP & Mysql" and have hit a brick wall, could anybody assist.

    I have a simple file upload script which takes the input field type "file" and uses the $_FILES array to take the tmp name and copies it to my desired directory, but I get the following error.

    failed to open stream: HTTP wrapper does not support writeable connections in C:\wamp\www\db-sites\ch10\fileUpload.php on line 9
    The script is extremely basic:
    PHP Code:
    $fileOrigName $_FILES['upload']['name'];
    $fileSize $_FILES['upload']['size'];
    $fileType $_FILES['upload']['type'];

    $targetFileName "http://localhost/db-sites/ch10/" $fileOrigName;

    if (!
    "failed to copy file.";
            <title>file has been uploaded</title>
            <h1>file has been uploaded</h1>
                <li><?php echo $fileTempName?></li>
                <li><?php echo $fileOrigName?></li>
                <li><?php echo $fileSize?></li>
                <li><?php echo $fileType?></li>
                <li><?php echo $targetFileName?></li>
    Which makes me think it is a config / directory thing with Wamp?

    If it is any help, no matter what file I upload I can never get windows to find the $fileTempName.

    Perhaps someone has had experience with WAMP before?

    Many thanks

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    The Netherlands
    153 Post(s)
    2 Thread(s)
    You should copy to a directory (like "c:\\wamp\\websites\\db-sites\\ch10") and not a URL.

    Also, for uploaded files it's better to use move_uploaded_file instead of copy
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts