Gooner Posted May 3, 2006 Share Posted May 3, 2006 HiI have recently changed web hosting from a local compnay to a VPS system (linux based).Everything is still working fine with my site, except one thing.I use a page on my site to upload PDF files into a directory (these pdf files can then be accessed via a browser). This was working fine on my old server, but now there seems to be an issue with files that already exist.If I upload a file called hello.pdf and there is already a file called hello.pdf in that directory, I want it to overwrite the original file (like it did on the old server). The trouble is, it won't overwrite them.If I upload a file that doesn't already exist, it uploads fine (yes, I have write permissions on the directory). If I then try to overwrite THIS file, again, it works fine.The trouble is when I try to overwtite a pdf file that was moved from the old server.The new files I upload have an owner and group both set as "apache". The existing files have a different user and group, which I think is what is causing the problem.Can anyone suggest a way I can get round this? I'd rather not delete and re-upload all the PDF files, as there are too many. Is there a way of "batch changing" all of the owner/group details within a directory, or is there a way in PHP that I can force it to overwrite the existing files that belong to a different user/group.Any help really appreciated.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/ Share on other sites More sharing options...
ober Posted May 3, 2006 Share Posted May 3, 2006 It sounds like the only way around this is to modify the permissions on all of those files. I don't think deleting them and re-uploading them is going to help. Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/#findComment-32906 Share on other sites More sharing options...
umasankar Posted May 3, 2006 Share Posted May 3, 2006 Hi,If you are using a Linux server, The Problem is File permission Only..Change that folder permission as 777. Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/#findComment-32915 Share on other sites More sharing options...
Gooner Posted May 3, 2006 Author Share Posted May 3, 2006 [!--quoteo(post=370861:date=May 3 2006, 07:38 AM:name=Umasankar Subramanian)--][div class=\'quotetop\']QUOTE(Umasankar Subramanian @ May 3 2006, 07:38 AM) [snapback]370861[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,If you are using a Linux server, The Problem is File permission Only..Change that folder permission as 777.[/quote]It IS a Linux server (VPS), running Fedora, and the folder where the PDF files are contained HAS a setting of 777.The problem remains however..... I can overwrite files uploaded by my script (owner = apache), but files that were FTP'd into the directory won't overwrite (owner = user).Thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/#findComment-32930 Share on other sites More sharing options...
craygo Posted May 3, 2006 Share Posted May 3, 2006 if you set the permissions on the folder, it will not make all the files under it the same. The new files you ad are getting the new permission, but the existing ones are not. You have to do a recursive chmod to make sure all the files and folders in the directory get the permissions. If you are trying to do this thru your FTP client, you will have to make sure you click all files and folder if your client even has that option. If you are doing it thru ssh then you have to use -R(make sure it is capital) to make all the files and folders that permission.Ray Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/#findComment-32934 Share on other sites More sharing options...
Gooner Posted May 3, 2006 Author Share Posted May 3, 2006 [!--quoteo(post=370880:date=May 3 2006, 08:26 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ May 3 2006, 08:26 AM) [snapback]370880[/snapback][/div][div class=\'quotemain\'][!--quotec--]if you set the permissions on the folder, it will not make all the files under it the same. The new files you ad are getting the new permission, but the existing ones are not. You have to do a recursive chmod to make sure all the files and folders in the directory get the permissions. If you are trying to do this thru your FTP client, you will have to make sure you click all files and folder if your client even has that option. If you are doing it thru ssh then you have to use -R(make sure it is capital) to make all the files and folders that permission.Ray[/quote]Thanks RayI use SecureFX as an FTP client.I select all the files in the directory as you stated, and changed them all to 777. It did them all, EXCEPT one PDF that was uploaded via the script I wrote. This file owner is apache (group = apache), whereas the rest have the owner user1.I deleted all the PDF files in the directory, changed the directory to 777 and re-uploaded them. All files were now 777. (same outcome as above). I now used my PHP script to upload a NEW file into this directory, but when I checked the permissions on this NEW file, they read 644 - even though the directory is set to 777.Any ideas why this is happening?Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/8953-copying-files-using-php/#findComment-32941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.