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!
First you have to fix your upload code to handle things correctly.
1. Check the error code first. There's a constant you can use to tell if the upload was successful.
2. If it's successful you need to validate. What kind of files do you want to allow?
3. If it's successful and valid then you can move the file to its new location. There is a specific function you should use to do this and it is not copy() or move().
Once that's ready you can fix the very minor problem you have now.
I already fix my code and it works perfectly in IIS webserver, however in fedora webserver i got the following error:
Warning: move_uploaded_file(upload/logo_img002.jpg): failed to open stream: Permission denied in /var/www/html/grd/upload_file.php
This is an issue with the folder permissions on your server - Apache has account privileges like every other user on the system, and your script is asking it to access a file that it does not have permission to access in some way.
What folder permissions are set for your "upload" folder? Remember that this is a two stage process - your script is telling PHP that it wants to read a file in the temporary upload folder (the location of which is specified in the php.ini settings) that PHP uses when it receives any files as a result of a form submission, and move this file to your "upload" folder. Normally, the temporary directory will have world-writable permissions (777) and is created automatically when you install PHP on a server, so the permissions for your "upload" folder are probably the reason why the move_uploaded_file() operation isn't working at the moment. Even if the permissions for your "upload" folder are correct (you would normally expect to see 755 or 775) the folder must also be owned either by the "apache" (or sometimes "nobody") user or owned by a user group to which the "apache" user belongs (this user group is also often called "apache").
Thank you very much mecha_godzilla for your great analysis, you are precisely right, the problem is the permission of my upload folder. I changed my upload folder permission and ownership, now my upload script is working properly. Thanks.