[PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!

2004-12-01 Thread Michael Leung
Hi all,
   I am still solving my upload script problems.
Here is the error Msg:
Warning: copy(/var/www/html/upload_files/Default.bk1)
[function.copy]: failed to open stream: Permission denied in
/var/www/html/simple_upload.php on line 77

My Upload Code:
$result  =  move_uploaded_file($temp_name, $file_path);

I started to think this is not only PHP , may be Apache problem too.
Anyone has some ideas?

I have tried to set my  upload directory into 777. Even I tried to use
sudo , giving apache as root permission and running system command
copy the file from the tmp directory to upload_files.

but still no success!! I have done some research on web, no one can
suggest a solution rather than chmod 777( I did that!)



yours,
michael

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



Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!

2004-12-01 Thread Gareth Williams
You could try chown user:group, where user and group are those apache 
runs in.

Is this script running on your own machine, or on a web server hosted 
somewhere?

On 1 Dec 2004, at 09:03, Michael Leung wrote:
Hi all,
   I am still solving my upload script problems.
Here is the error Msg:
Warning: copy(/var/www/html/upload_files/Default.bk1)
[function.copy]: failed to open stream: Permission denied in
/var/www/html/simple_upload.php on line 77
My Upload Code:
$result  =  move_uploaded_file($temp_name, $file_path);
I started to think this is not only PHP , may be Apache problem too.
Anyone has some ideas?
I have tried to set my  upload directory into 777. Even I tried to use
sudo , giving apache as root permission and running system command
copy the file from the tmp directory to upload_files.
but still no success!! I have done some research on web, no one can
suggest a solution rather than chmod 777( I did that!)

yours,
michael
--
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


Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!

2004-12-01 Thread Scott Fletcher
The directory folder where you upload the file(s) and folder(s) inito must
have the ownership of Apache and the permission of 755.  Then you'll have no
trouble uploading file(s)/folder(s) into it since Apache would have the
permission to create the file(s)/folder(s) where none exist or update them
only if the file(s)/folder(s) was created by Apache in the past.  If those
file(s)/folder(s) weren't created by Apache but by you or someone then it
wouldn't work because the ownership would be different, you'll need to
change the ownership and permission to what Apache can use.

This is from what I had noticed and had no trouble with them since then.
When I move the files from 1 webserver to another, I alway check the
ownership and correct it if it is wrong the first time.

Scott

Gareth Williams [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 You could try chown user:group, where user and group are those apache
 runs in.

 Is this script running on your own machine, or on a web server hosted
 somewhere?

 On 1 Dec 2004, at 09:03, Michael Leung wrote:

  Hi all,
 I am still solving my upload script problems.
  Here is the error Msg:
  Warning: copy(/var/www/html/upload_files/Default.bk1)
  [function.copy]: failed to open stream: Permission denied in
  /var/www/html/simple_upload.php on line 77
 
  My Upload Code:
  $result  =  move_uploaded_file($temp_name, $file_path);
 
  I started to think this is not only PHP , may be Apache problem too.
  Anyone has some ideas?
 
  I have tried to set my  upload directory into 777. Even I tried to use
  sudo , giving apache as root permission and running system command
  copy the file from the tmp directory to upload_files.
 
  but still no success!! I have done some research on web, no one can
  suggest a solution rather than chmod 777( I did that!)
 
 
 
  yours,
  michael
 
  -- 
  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



Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!

2004-12-01 Thread Richard Lynch
 Hi all,
I am still solving my upload script problems.
 Here is the error Msg:
 Warning: copy(/var/www/html/upload_files/Default.bk1)
 [function.copy]: failed to open stream: Permission denied in
 /var/www/html/simple_upload.php on line 77

 My Upload Code:
 $result  =  move_uploaded_file($temp_name, $file_path);

 I started to think this is not only PHP , may be Apache problem too.
 Anyone has some ideas?

 I have tried to set my  upload directory into 777. Even I tried to use
 sudo , giving apache as root permission and running system command
 copy the file from the tmp directory to upload_files.

 but still no success!! I have done some research on web, no one can
 suggest a solution rather than chmod 777( I did that!)

Does the PHP user (aka the Apache user) have permission to *READ* from and
*WRITE* to the TMP directory?

You may be attacking the wrong side of the equation.

I believe PHP will complain the same way whether it can't read/write /tmp,
or it can't read/write to your destination directory.

PS

For God's sake change your permissions back to something reasonable, and
stop running Apache as root, *NOW*.

Actually, from a more practical stand-point, *change* your upload
destination to some place *outside* the web tree, so that when PHP dumps
stuff in there, possibly some stuff you don't *want* in there, possibly
because some user is playing games with your site, then you can write some
code to examine the content before doing anything with it -- Specifically
*before* it ends up living on your public web-server.

Example:  Bad guy decides your server would be a nice place to upload not
a worksheet, but his latest cracked video game or highly-popular software
package or, ahem, graphic images.  Then *your* server becomes a free
source of illegal content, or content you are not in the business of
hosting.  That's bad.  Real bad.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Upload is not working ( Permission Problem), I tried a number of ways , still no success!!!!!

2004-12-01 Thread Michael Leung
Hi Scott,
  Thank you for your help, but I have tried to user chown -r
apache:apache upload_files.
this is not working. 

yours,
Michael

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



[PHP] Upload is not working

2004-11-21 Thread Michael Leung
Hi all,
   I am implementing a upload file PHP program. The script is not
working. it keeps on generating the permission Error.
I am not very sure this is PHP or Apache problem. But one things I can
sure I changed all upload file dir in 777.

Anyone can help? Or are there any people facing this kind of problem too?

yours,
Michael Leung

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



Re: [PHP] Upload is not working

2004-11-21 Thread Jason Wong
On Monday 22 November 2004 10:56, Michael Leung wrote:

I am implementing a upload file PHP program. The script is not
 working. it keeps on generating the permission Error.
 I am not very sure this is PHP or Apache problem. But one things I can
 sure I changed all upload file dir in 777.

The user running the apache process (apache or www or nobody or whatever) 
needs execute permissions ('x') on the destination directory (which you 
already have in the form of 777) AND on all its parent directories.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
RADIO SHACK LEVEL II BASIC
READY
_
*/

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



[PHP] Upload script not working

2004-08-23 Thread Lizet Peña de Sola

Hi all:

I have the following script to upload files to the server, it works
partially as only a few bytes of the file are uploaded, is the script wrong
or am I missing some setting at the server?
Tia, 
Lizet

userfile=$_FILES['userfile']['tmp_name'];
// $userfile_name is the original file name without spaces
$userfile_name=str_replace( ,_,$_FILES['userfile']['name']);
// $userfile_size the size in bytes
$userfile_size=$_FILES['userfile']['size'];
//$userfile_type is mime type e.g. image/gif
$userfile_type=$_FILES['userfile']['type'];
// $userfile_error is any error encountered
$userfile_error=$_FILES['userfile']['error'];
if($userfile_error  0){
   $str=Problem: ;
   switch ($userfile_error){
  case 1: $str=$str.error 1; break;
   case 2: $str=$str.error2; break;
   case 3: $str=$str.erro3; break;
   case 4: $str=$str.error4; break;
   } 
   exit; 
}
$upfile= 'files/'.$userfile_name;
$temp1=is_uploaded_file($userfile);
if($temp1){
$temp2=move_uploaded_file($userfile,$upfile);
if(!$temp2){
 $str=Problem: The file could not be moved.;
  //exit;
 }
 
}
else{
$str=Problem: file corrupted: .$userfile_name;
}
//reformat the file contents:
$fp= fopen($upfile,'r');
$contents = fread($fp, filesize($upfile));
fclose($fp);

$contents= strip_tags($contents);
$fp= fopen($upfile,'w');
fwrite($fp,$contents);
fclose($fp);

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



Re: [PHP] Upload script not working

2004-08-23 Thread John Holmes
From: Lizet Peña de Sola [EMAIL PROTECTED]
I have the following script to upload files to the server, it works
partially as only a few bytes of the file are uploaded, is the script 
wrong
or am I missing some setting at the server?
Tia,
Lizet

userfile=$_FILES['userfile']['tmp_name'];
// $userfile_name is the original file name without spaces
$userfile_name=str_replace( ,_,$_FILES['userfile']['name']);
// $userfile_size the size in bytes
$userfile_size=$_FILES['userfile']['size'];
//$userfile_type is mime type e.g. image/gif
$userfile_type=$_FILES['userfile']['type'];
// $userfile_error is any error encountered
$userfile_error=$_FILES['userfile']['error'];
if($userfile_error  0){
  $str=Problem: ;
  switch ($userfile_error){
 case 1: $str=$str.error 1; break;
  case 2: $str=$str.error2; break;
  case 3: $str=$str.erro3; break;
  case 4: $str=$str.error4; break;
  }
  exit;
}
$upfile= 'files/'.$userfile_name;
$temp1=is_uploaded_file($userfile);
if($temp1){
   $temp2=move_uploaded_file($userfile,$upfile);
   if(!$temp2){
$str=Problem: The file could not be moved.;
 //exit;
}
}
else{
   $str=Problem: file corrupted: .$userfile_name;
}
//reformat the file contents:
$fp= fopen($upfile,'r');
$contents = fread($fp, filesize($upfile));
fclose($fp);
$contents= strip_tags($contents);
$fp= fopen($upfile,'w');
fwrite($fp,$contents);
fclose($fp);
I don't notice anything wrong with the script after glancing through it. If 
you take out the end portion where you strip the tags from the file, so you 
still end
up with a smaller file as a result? Maybe strip_tags() is removing more 
content than you think it is? Either way, you're going to end up with a 
smaller file.

---John Holmes... 

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


RE: [PHP] Upload script not working

2004-08-23 Thread Lizet Peña de Sola
Hello Jones, thanks for looking at the code, will try the uploading without
stripping the tags, I've tried with pdf files without success.
Lizet



-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 23, 2004 3:02 PM
To: Lizet Peña de Sola; [EMAIL PROTECTED]
Subject: Re: [PHP] Upload script not working


From: Lizet Peña de Sola [EMAIL PROTECTED]
 I have the following script to upload files to the server, it works 
 partially as only a few bytes of the file are uploaded, is the script 
 wrong or am I missing some setting at the server?
 Tia,
 Lizet

 userfile=$_FILES['userfile']['tmp_name'];
 // $userfile_name is the original file name without spaces 
 $userfile_name=str_replace( ,_,$_FILES['userfile']['name']);
 // $userfile_size the size in bytes 
 $userfile_size=$_FILES['userfile']['size'];
 //$userfile_type is mime type e.g. image/gif 
 $userfile_type=$_FILES['userfile']['type'];
 // $userfile_error is any error encountered 
 $userfile_error=$_FILES['userfile']['error'];
 if($userfile_error  0){
   $str=Problem: ;
   switch ($userfile_error){
  case 1: $str=$str.error 1; break;
   case 2: $str=$str.error2; break;
   case 3: $str=$str.erro3; break;
   case 4: $str=$str.error4; break;
   }
   exit;
 }
 $upfile= 'files/'.$userfile_name; $temp1=is_uploaded_file($userfile);
 if($temp1){
$temp2=move_uploaded_file($userfile,$upfile);
if(!$temp2){
 $str=Problem: The file could not be moved.;
  //exit;
 }

 }
 else{
$str=Problem: file corrupted: .$userfile_name;
 }
 //reformat the file contents:
 $fp= fopen($upfile,'r');
 $contents = fread($fp, filesize($upfile));
 fclose($fp);

 $contents= strip_tags($contents);
 $fp= fopen($upfile,'w');
 fwrite($fp,$contents);
 fclose($fp);

I don't notice anything wrong with the script after glancing through it. If 
you take out the end portion where you strip the tags from the file, so you 
still end
up with a smaller file as a result? Maybe strip_tags() is removing more 
content than you think it is? Either way, you're going to end up with a 
smaller file.

---John Holmes... 

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



RE: [PHP] Upload script not working

2004-08-23 Thread Lizet Peña de Sola

Hello again, tried to remove the last part and the script worked, it looks
like strip_tags strips more than tags...
Thanks a lot
Lizet

-Original Message-
From: John Holmes [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 23, 2004 3:02 PM
To: Lizet Peña de Sola; [EMAIL PROTECTED]
Subject: Re: [PHP] Upload script not working


From: Lizet Peña de Sola [EMAIL PROTECTED]
 I have the following script to upload files to the server, it works 
 partially as only a few bytes of the file are uploaded, is the script 
 wrong or am I missing some setting at the server?
 Tia,
 Lizet

 userfile=$_FILES['userfile']['tmp_name'];
 // $userfile_name is the original file name without spaces 
 $userfile_name=str_replace( ,_,$_FILES['userfile']['name']);
 // $userfile_size the size in bytes 
 $userfile_size=$_FILES['userfile']['size'];
 //$userfile_type is mime type e.g. image/gif 
 $userfile_type=$_FILES['userfile']['type'];
 // $userfile_error is any error encountered 
 $userfile_error=$_FILES['userfile']['error'];
 if($userfile_error  0){
   $str=Problem: ;
   switch ($userfile_error){
  case 1: $str=$str.error 1; break;
   case 2: $str=$str.error2; break;
   case 3: $str=$str.erro3; break;
   case 4: $str=$str.error4; break;
   }
   exit;
 }
 $upfile= 'files/'.$userfile_name; $temp1=is_uploaded_file($userfile);
 if($temp1){
$temp2=move_uploaded_file($userfile,$upfile);
if(!$temp2){
 $str=Problem: The file could not be moved.;
  //exit;
 }

 }
 else{
$str=Problem: file corrupted: .$userfile_name;
 }
 //reformat the file contents:
 $fp= fopen($upfile,'r');
 $contents = fread($fp, filesize($upfile));
 fclose($fp);

 $contents= strip_tags($contents);
 $fp= fopen($upfile,'w');
 fwrite($fp,$contents);
 fclose($fp);

I don't notice anything wrong with the script after glancing through it. If 
you take out the end portion where you strip the tags from the file, so you 
still end
up with a smaller file as a result? Maybe strip_tags() is removing more 
content than you think it is? Either way, you're going to end up with a 
smaller file.

---John Holmes... 

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



Re: [PHP] Upload script not working

2004-08-23 Thread John Holmes
From: Lizet Peña de Sola [EMAIL PROTECTED]

Hello Jones, thanks for looking at the code,
will try the uploading without
stripping the tags, I've tried with pdf files
without success.
strip_tags on a PDF file is a bad idea. strip_tags() is only meant for text 
files that may contain HTML tags that you want to remove...

---John Holmes... 

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


RE: [PHP] Upload script not working

2004-08-23 Thread Lizet Peña de Sola
Thanks, I better check the file type first then...


strip_tags on a PDF file is a bad idea. strip_tags() is only meant for text 
files that may contain HTML tags that you want to remove...

---John Holmes... 

-- 
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