Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7301 > unrolled thread
| Started by | sathyashrayan <sathyashrayan@gmail.com> |
|---|---|
| First post | 2012-10-12 23:42 -0700 |
| Last post | 2012-10-13 22:27 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
Curl chmod file transfer problem... sathyashrayan <sathyashrayan@gmail.com> - 2012-10-12 23:42 -0700
Re: Curl chmod file transfer problem... Jerry Stuckle <jstucklex@attglobal.net> - 2012-10-13 10:25 -0400
Re: Curl chmod file transfer problem... "J.O. Aho" <user@example.net> - 2012-10-13 22:27 +0200
| From | sathyashrayan <sathyashrayan@gmail.com> |
|---|---|
| Date | 2012-10-12 23:42 -0700 |
| Subject | Curl chmod file transfer problem... |
| Message-ID | <b652077b-7422-466c-9c14-cb134a8d0993@googlegroups.com> |
Group, I am facing a problem with curl file transfer. I have one form in a site A. The form collects some data and also a file (file upload). When that form gets submitted it stores the data in the site A and also stores the data in site B( another server ). The data are getting saved from server A to server B. But the file transfer with curl has file permission problem. My file need to have 0777 chmod for the curl to read and transfer. What I do is I read the file with chunk_split(base64_encode(file_get_contents($file))); from site A and transfer that data to site B (another server). If i change the permission in site A's file that needed to be read, through shell as a root, chmod 777, and make a curl transfer then it is getting stored perfectly in server B. But when i make a file transfer through a code then i could not use chmod function because the file is stored as a "apache" in user but not as a "root". Detailed explanation: --------------------- I have a joomla site with a enquiry form in chronoform. I have some text and also one file upload in the chrnoform. When a user asks for a quote, those data need to stored in a sugerCRM (sugarCRM leads module, web to leads form, campaign). Joomla site is in server A and sugarCRM is in server B. The uploaded file will be stored in the notes table (mysql) of sugarCRM. All worked if i manually change the file to chmode 777. But i want it happen when some one upload the file in the chronoform. I tried chmod through a php code but it does not work because the program that creates the file will have "apache" as a user not as "root" user. Any workaround? I just need to know if changing the file permission from 0644 to 0777 through program. Any help? If anyone wants i could pastebin the code and post it here.
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-10-13 10:25 -0400 |
| Message-ID | <k5btl3$hdn$1@dont-email.me> |
| In reply to | #7301 |
On 10/13/2012 2:42 AM, sathyashrayan wrote: > Group, > I am facing a problem with curl file transfer. I have one form in > a site A. The form collects some data and also a file (file upload). > When that form gets submitted it stores the data in the site A and > also stores the data in site B( another server ). The data are > getting saved from server A to server B. But the file transfer > with curl has file permission problem. My file need to have > 0777 chmod for the curl to read and transfer. > > What I do is I read the file with > > chunk_split(base64_encode(file_get_contents($file))); > > from site A and transfer that data to site B (another server). If > i change the permission in site A's file that needed to be read, > through shell as a root, chmod 777, and make a curl transfer then > it is getting stored perfectly in server B. But when i make a file > transfer through a code then i could not use chmod function because > the file is stored as a "apache" in user but not as a "root". > That is correct. A user file should NEVER be stored as the root user. But why are you setting the execute bit on a non-executable file? > Detailed explanation: > --------------------- > I have a joomla site with a enquiry form in chronoform. I have some > text and also one file upload in the chrnoform. When a user asks > for a quote, those data need to stored in a sugerCRM (sugarCRM > leads module, web to leads form, campaign). Joomla site is in > server A and sugarCRM is in server B. The uploaded file will be > stored in the notes table (mysql) of sugarCRM. All worked if i > manually change the file to chmode 777. But i want it happen > when some one upload the file in the chronoform. I tried chmod > through a php code but it does not work because the program > that creates the file will have "apache" as a user not as > "root" user. Any workaround? I just need to know if changing > the file permission from 0644 to 0777 through program. Any > help? If anyone wants i could pastebin the code and post it here. > You can't chmod the file unless you are the owner or the root user. The question is why you can't read the file in PHP. With 644 permissions, that should be possible. I think you need to read up and better understand Linux administration, especially with regard to permissions, users and groups. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2012-10-13 22:27 +0200 |
| Message-ID | <adu150FfdejU1@mid.individual.net> |
| In reply to | #7301 |
On 13/10/12 08:42, sathyashrayan wrote: > I have a joomla site with a enquiry form in chronoform. I have some text and also one file upload in > the chrnoform. When a user asks for a quote, those data need to stored in a sugerCRM (sugarCRM leads > module, web to leads form, campaign). Joomla site is in server A and sugarCRM is in server B. > The uploaded file will be stored in the notes table (mysql) of sugarCRM. All worked if i manually > change the file to chmode 777. But i want it happen when some one upload the file in the chronoform. > I tried chmod through a php code but it does not work because the program that creates the file will > have "apache" as a user not as "root" user. Any workaround? I just need to know if changing the > file permission from 0644 to 0777 through program. Any help? If anyone wants i could pastebin > the code and post it here. Seems you have a bit lack knowledge of file permissions, the 0644 will be more than enough for any user to read the file (4 is the read bit), so there is no need to change a file to 777 (7 = 1 + 2 + 4), as when you read a file you don't need to be able to execute it nor be able to write to it. Change owner will not make a difference, in this case, as all users are allowed to read the file. Change a file so it's owned by root usually means that the file will have one less user who can do what ever they want with the file. Have you checked that the user who is running the curl script (I'm assuming you run it on server A and post it to the suragCRM on server B) has the right to access the directory where the file is stored. For example you have /var/www/htdocs/upload Then you may have $ ls -ld /var/ drwxr-xr-x 14 root root 4096 Oct 31 2011 /var/ $ ls -ld /var/www drwxr-xr-x 3 root root 8 Jul 10 2008 /var/www $ ls -ld /var/www/htdocs/ drwxr-xr-x 3 apache apache 8 Jul 10 2008 /var/www/htdocs/ $ ls -ld /var/www/htdocs/upload/ drwxr-x--- 2 apache apache 4096 Jul 10 2011 /var/www/htdocs/upload/ In this case no one else than apache user, root and those part of the apache group has the privilege to access the files in the upload directory. No matter who owns the file or which file privileges bits has been turned on. If you are running your script as apache, then the most likely reason why your curl fails it that the path is wrong. In this case I suggest you use syslog() to log what you are doing in your script, specially which paths you are trying to use. -- //Aho
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web