move_uploaded_file problem?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

move_uploaded_file problem?

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: move_uploaded_file problem?

Post 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?
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

Re: move_uploaded_file problem?

Post by kalpesh »

Thanks tasaris.
U again help me.
I am misconsidering the function.
Thanks .
now It works perfectly with copy function.
Post Reply