Re: [PHP] File Copy

2004-10-20 Thread Silvio Porcellana
Aidal wrote:
Hi NG.
I'm experiencing some problems when trying to copy a file from one location
to another on the web server.
example:
dir1/subdir1/some_image_name.jpg  --  dir2/subdir2/some_new_image_name.jpg
When I do this the file permissions changes and I'm no longer the owner of
the file. I tried to use chmod('the_new_file', 0777); but it doesn't work,
because chmod() wont let me change the permissions since I'm not the owner
of this new file.
The owner should now be the user the Web server is running as.
To change file ownerships you need to use the PHP FTP functions.
Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
HTH, cheers!
Silvio Porcellana
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Copy

2004-10-20 Thread Aidal
ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.

I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(

Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Aidal wrote:
  Hi NG.
 
  I'm experiencing some problems when trying to copy a file from one
location
  to another on the web server.
 
  example:
 
  dir1/subdir1/some_image_name.jpg  --
dir2/subdir2/some_new_image_name.jpg
 
  When I do this the file permissions changes and I'm no longer the owner
of
  the file. I tried to use chmod('the_new_file', 0777); but it doesn't
work,
  because chmod() wont let me change the permissions since I'm not the
owner
  of this new file.
 
 The owner should now be the user the Web server is running as.
 To change file ownerships you need to use the PHP FTP functions.
 Check out these pages: http://php.libero.it/manual/en/ref.ftp.php

 HTH, cheers!
 Silvio Porcellana

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Copy

2004-10-20 Thread M. Sokolewicz
how about setting the correct umask. Or else su'ing to the correct user 
before moving it.

Aidal wrote:
ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(
Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Aidal wrote:
Hi NG.
I'm experiencing some problems when trying to copy a file from one
location
to another on the web server.
example:
dir1/subdir1/some_image_name.jpg  --
dir2/subdir2/some_new_image_name.jpg
When I do this the file permissions changes and I'm no longer the owner
of
the file. I tried to use chmod('the_new_file', 0777); but it doesn't
work,
because chmod() wont let me change the permissions since I'm not the
owner
of this new file.
The owner should now be the user the Web server is running as.
To change file ownerships you need to use the PHP FTP functions.
Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
HTH, cheers!
Silvio Porcellana
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Copy

2004-10-20 Thread Aidal
ERR, I meant I tried ftp_exec(), ftp_raw() is a PHP 5 function too...

Aidal [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.

 I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though
:(

 Silvio Porcellana [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Aidal wrote:
   Hi NG.
  
   I'm experiencing some problems when trying to copy a file from one
 location
   to another on the web server.
  
   example:
  
   dir1/subdir1/some_image_name.jpg  --
 dir2/subdir2/some_new_image_name.jpg
  
   When I do this the file permissions changes and I'm no longer the
owner
 of
   the file. I tried to use chmod('the_new_file', 0777); but it doesn't
 work,
   because chmod() wont let me change the permissions since I'm not the
 owner
   of this new file.
  
  The owner should now be the user the Web server is running as.
  To change file ownerships you need to use the PHP FTP functions.
  Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
 
  HTH, cheers!
  Silvio Porcellana

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Copy

2004-10-20 Thread Chris Dowell
Aidal
Could you post the relevant parts of your code so we have a little 
context to work in?

You say you're copying a file from one location to another on the same 
server. If this is the case you are very unlikely to be in need of the 
ftp family of functions, which are only valid for use over an 
established ftp connection.

I suspect that the file is indeed now owned by the webserver
has it changed from aidal:somegroup to nobody:nogroup or something like 
that?

Post us some code and the answers you get will probably be more useful
Cheers
Chris
Aidal wrote:
ftp_chmod() is part of PHP 5 and I'm working with PHP 4.3.1.
I tried the ftp_raw('CHMOD 777 filename.jpg'); doesn't work either though :(
Silvio Porcellana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Aidal wrote:
Hi NG.
I'm experiencing some problems when trying to copy a file from one
location
to another on the web server.
example:
dir1/subdir1/some_image_name.jpg  --
dir2/subdir2/some_new_image_name.jpg
When I do this the file permissions changes and I'm no longer the owner
of
the file. I tried to use chmod('the_new_file', 0777); but it doesn't
work,
because chmod() wont let me change the permissions since I'm not the
owner
of this new file.
The owner should now be the user the Web server is running as.
To change file ownerships you need to use the PHP FTP functions.
Check out these pages: http://php.libero.it/manual/en/ref.ftp.php
HTH, cheers!
Silvio Porcellana

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Copy

2004-10-20 Thread Silvio Porcellana
Chris Dowell wrote:
Aidal
Could you post the relevant parts of your code so we have a little 
context to work in?

You say you're copying a file from one location to another on the same 
server. If this is the case you are very unlikely to be in need of the 
ftp family of functions, which are only valid for use over an 
established ftp connection.

You can indeed establish an FTP connection to your local server - provided it has an FTP 
server running.
The files are actually copied by Apache (or whatever Web server he's using), so this is 
why the server becomes the owner.

I suspect that the file is indeed now owned by the webserver
has it changed from aidal:somegroup to nobody:nogroup or something like 
that?

I guess this is the problem Aidal is experiencing.
In order to maintain file ownserships, what he can do (since he doesn't have PHP 5) is 
copy the file with 'ftp_fput()' [http://php.libero.it/manual/en/function.ftp-fput.php].
That is, he opens the files he wants to copy and PUTs it via this function. Since he is 
logged in - using 'ftp_connect()' and 'ftp_login()' - the files will be owned by the user 
he used to login.

My .2 euros...
Cheers,
Silvio Porcellana
snip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Copy

2004-10-20 Thread Dusty Bin
Aidal,
	presumably, your server had the write to copy the file, otherwise the 
copy would have failed.  Is the only problem that you don't have the 
correct permissions on the copied file??  if so check out
http://www.php.net/manual/en/function.umask.php.  If you set the umask 
before you copy, you should have the correct permissions.

Best regards. . . Dusty
Silvio Porcellana wrote:
Chris Dowell wrote:
Aidal
Could you post the relevant parts of your code so we have a little 
context to work in?

You say you're copying a file from one location to another on the same 
server. If this is the case you are very unlikely to be in need of the 
ftp family of functions, which are only valid for use over an 
established ftp connection.

You can indeed establish an FTP connection to your local server - 
provided it has an FTP server running.
The files are actually copied by Apache (or whatever Web server he's 
using), so this is why the server becomes the owner.

I suspect that the file is indeed now owned by the webserver
has it changed from aidal:somegroup to nobody:nogroup or something 
like that?

I guess this is the problem Aidal is experiencing.
In order to maintain file ownserships, what he can do (since he doesn't 
have PHP 5) is copy the file with 'ftp_fput()' 
[http://php.libero.it/manual/en/function.ftp-fput.php].
That is, he opens the files he wants to copy and PUTs it via this 
function. Since he is logged in - using 'ftp_connect()' and 
'ftp_login()' - the files will be owned by the user he used to login.

My .2 euros...
Cheers,
Silvio Porcellana
snip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] file copy

2003-02-03 Thread Maxim Maletsky
You must change the headers for the file so it is being downloaded.
Something like this:

header('Content-Type: GIF');   // not sure of this one
header('Content-Length: ' . filesize('file.gif'));
header(Content-Disposition: attachment; 
filename=\file.gif\);



--
Maxim Maletsky
[EMAIL PROTECTED]



Cenk Uysal [EMAIL PROTECTED] wrote... :

 hi,
 
 how can i copy a file from web to my local disk?
 
 http://www.xxx.com/xxx.gif
 
 i try to get xxx.gif to my local disk...
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php