Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts

    simple upload scripts problem

    Hi Guys,

    this tiny bit of code doesnt seem to be moving the files to the destination folder:

    PHP Code:
         foreach ($_FILES['nzb']['name'] as $key => $value) {
         
         
    $target "nzbs/";
         
    $target $target_path.basename($value); 
         
         
    move_uploaded_file($_FILES['nzb']['tmp_name'][$key], $target);
         
         } 
    when i print_r(); all the variables are displayed in the array fine, have i missed a bit of code at all?

    thanks guys

    Graham

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Post your form code.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,049
    Thanks
    2
    Thanked 317 Times in 309 Posts
    Echo out $target, I think you will find it does not contain what you expect -
    Code:
         $target = "nzbs/"; 
         $target = $target_path.basename($value);
    I think you want the first variable there to be $target_path
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    134
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hi Guys,

    changed it slightly:

    PHP Code:
         foreach ($_FILES['nzb']['name'] as $key => $value) {
         
         
    $target_path "nzbs/";
         
    $target_path $target_path basename($value); 
         
         echo 
    $target_path;
         
         
    move_uploaded_file($_FILES['nzb']['tmp_name'][$key], $target_path);
         
         } 
    when i echo out target_path i get:

    PHP Code:
    nzbs/nzbs
    it should only be 1 nzbs, but it adds two on for some reason

    cheers

    Graham
    Last edited by graham23s; 08-31-2007 at 12:19 AM.


  •  

    Posting Permissions

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