Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2002
    Thanked 0 Times in 0 Posts

    Uploading images

    I have a piece of code that I've used before to upload an image from a form to a specified folder, and it has worked fine.

    PHP Code:
    copy($_FILES['img1']['tmp_name'], "images/userpics/".$_FILES['img1']['name']) or die("Couldn't copy the file!"); 
    I need to use this again, but this time the folder into which the image is uploaded will depend on one of the options selected in the form. The user selects a category for the image and it is placed in the corresponding folder.

    I've obtained the name of the folder from the form and it is stored in the variable $imgfolder. The code I have for the actual upload is as follows, but I am getting a failure on it.

    PHP Code:
    copy($_FILES['imgfull']['tmp_name'], "images/".$imgfolder."/".$_FILES['imgfull']['name']) or die("Couldn't copy the file!"); 
    Can anyone see what is wrong with this?

  • #2
    Super Moderator
    Join Date
    May 2002
    Perth Australia
    Thanked 101 Times in 99 Posts
    whats the error ? , my crystal ball suggests "permission denied" (in which case you need to chmod the folders appropriately) but I dont believe in fortune tellers
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


    Posting Permissions

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