Page 1 of 1

move_uploaded_file problem?

Posted: Tue Feb 03, 2009 2:49 am
by kalpesh
Hi,
I have problem in moving same files to different folders.
There is below my code.
I stored city name in array.
Then for each city i want to upload image file in that image city folder (e.g Banner_NewYork).
If there are 4 cities then it will upload only in one city image folder which is first city in array and second time he show the message "Could not upload";

Code: Select all

 
 if($City)//$city is an array storing city name
        {
            foreach($City as $cityname)
            {
                $bannername="Banner_".$cityname; //create folder name which is existing
                     if(is_dir("../../banner/".$bannername)){
                            if(strlen($_FILES['ProductBanner']['name'])>0){
                                $ProductBanner = $_FILES['ProductBanner']['name'];
move_uploaded_file($_FILES['ProductBanner']['tmp_name'],"../../banner/".$bannername."/".$ProductBanner) or die("Could not Upload") ;       
                                }
                            }
                }
}
 
Please Help me.
Thanks in advance.

Re: move_uploaded_file problem?

Posted: Tue Feb 03, 2009 3:03 am
by requinix
It seems you've completely forgotten what it means to move a file.

Once it's been moved it's no longer there. Gone. Disappeared. Missing.

Maybe you want to copy the file?

Re: move_uploaded_file problem?

Posted: Tue Feb 03, 2009 3:22 am
by kalpesh
Thanks tasaris.
U again help me.
I am misconsidering the function.
Thanks .
now It works perfectly with copy function.