[PHP] POST multipart/form-data temp files not being created. File_upload directive is resetting to "No."

2005-03-11 Thread Shawn Kelly

hello php.general:
I want to send a file through an HTML form to my Linux server.

Newbie to PHP, but I have been patient in inverse proportion to my
knowledge.  I have seen many confused people with similar problems and their
respective solutions in my quest (!), but still no avail towards my own.


Here are my questions (first):
What sort of monster could possibly cause ini_get("file_uploads") to return
Off even though php.ini has file_uploads = On?
And how can I slay this monster?


Here is my history (last):
I am running redhat, apache 1.3.23, & PHP 4.3.9.  upload_tmp_dir =
"/var/www/ultmp" and apache runs as user "apache".

I have a form which POSTs a request of multipart/form-data -- specifically a
binary file -- to a php script.  I am using "LiveHTTPHeaders" extension for
FireFox to prove that my browser /is/ in fact composing this request in a
syntactically appropriate idiom.  However, in PHP the $_FILES array comes
out of print_r() as just "array ( )" always, and no file is being sent to
the upload directory.

This is my initial problem, which is a doosie, because it encompases a vast
scope.  BUT I think I've pinned the cause down to something that PHP expert
may be able to help with!


First thought was that the cause was insufficient permissions for the
"apache" user:
I chmod'ed the directory /var/www/ultmp to 777 and chown'ed it to apache.  I
am assuming that the temp directory does not have to be (and really should
not be) a world-readable.  I was able to determine that the cause /is not/ a
problem with the permissions of the user "apache" by adding into my PHP a
call to mkdir() which creates a directory off of the directory in my
"upload_tmp_dir" directive.  (And verified that the directory does in fact
begin to exist following the script's execution.)


Second thought was that the cause was with php.ini or http.conf.
I have checked apache error_log: nothing.  I tried setting upload_tmp_dir to
(nothing), to "/var/www/ultmp/", and to "/var/www/ultmp"; still nothing.  I
must admit that I still have not completely determined the cause to be
not-apache, but I have no leads except this one in PHP, and my searches of
http.conf yeild no tangible results.

I am using a wonderful script [http://www.epiware.com/scripts/upload.php] to
troubleshoot my uploading woes.  I am unable to upload small and large files
alike.

In my php.ini file, I have the following directives/values
 file_uploads = On
 upload_tmp_dir = "/var/www/ultmp"
 upload_max_file_size = 2M
 max_execution_time = 30
 post_max_size = 2M


But the spark in my curiousity: when I do phpinfo() in my
post-action-script, I see for the file_upload directive the "Local Value"
goes to Off.  My guess is that what ever is causing "Local Value" to go to
Off even though "Master Value" is On (I did try restarting the server) is
also causing my $_FILES variable to be empty and my actual file data to be
thrown into the trash.




If you read all the way to the bottom, I must thank you for your time!
My respect and admiration to the PHP community!

cudos,
Shawn Kelly.

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



[PHP] Re: Sending data via POST

2005-03-11 Thread Shawn Kelly



This is from php.net:
Just change the $out to fill with your POST request 
(instead of the GET).  Works good, you can change ports. :)
 
$fp = fsockopen("www.example.com", 80, 
$errno, $errstr, 30);if (!$fp) {   echo 
"$errstr ($errno)\n";} 
else {   $out = "GET / HTTP/1.1\r\n";   $out .= "Host: 
www.example.com\r\n";   $out .= "Connection: Close\r\n\r\n";   fwrite($fp, $out);   while 
(!feof($fp)) {       
echo fgets($fp, 128);   }   
fclose($fp);}

  "Todd Cary" <[EMAIL PROTECTED]> wrote in 
  message news:[EMAIL PROTECTED]...Currently 
  I send data to another page by usingheader("Location: http://" . $_SERVER['HTTP_HOST'] .                  
    dirname($_SERVER['PHP_SELF']) .     
  "/" . $relative_url  .     
  "?" . $my_data);My client would like the data passed via a 
  POST rather than in the URL.Can this be done and if so, 
  how?Many thanksTodd
  -- 


Re: [PHP] POST multipart/form-data temp files not being created. File_upload directive is resetting to "No."

2005-03-11 Thread Shawn Kelly
Richard Lynch you are my new best friend!  grep -n uploads
/etc/httpd/conf/httpd.conf tells me "279:php_admin_value file_uploads off".
I don't know how I could have missed it!

I changed httpd.conf to have php_admin_value file_uploads On and everything
worked like it was supposed to this morning before I had this headache!

My weekend officially begins!
*virtual beers all around*

/s

"Richard Lynch" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Here are my questions (first):
> > What sort of monster could possibly cause ini_get("file_uploads") to
> > return
> > Off even though php.ini has file_uploads = On?
>
> First and foremost, confirm that the php.ini you changed is the same file
> PHP is actually using.
>
> Create a phpinfo.php file with: 
> and surf to it on your server.
> Use browser "Find" menu to find "php.ini" and see where PHP is expecting
> php.ini to be.  Put php.ini there.
>
> Second most common cause of this is changing php.ini and not re-starting
> Apache (or *thinking* you re-started apache, but you didn't)
>
> You can maybe check: http://example.com/server-status (or is it
> server_status) to see Apache up-time.  (Alas, nobody has PHP uptime for
> you)
>
> It's also possible that you would have an .htaccess file turning
> file_uploads back Off in your directory, or even an auto_prepend_file
> turning them Off, but that's pretty unlikely to happen without you knowing
> it.
>
> Very remotely possible, your ISP webhost could have hacked PHP source to
> make file_uploads be Off no matter what you do, cuz they really hate
> file_uploads.
>
> > And how can I slay this monster?
>
> Move php.ini and/or re-start Apache
>
> > Here is my history (last):
> > I am running redhat, apache 1.3.23, & PHP 4.3.9.  upload_tmp_dir =
> > "/var/www/ultmp" and apache runs as user "apache".
> >
> > I have a form which POSTs a request of multipart/form-data --
specifically
> > a
> > binary file -- to a php script.  I am using "LiveHTTPHeaders" extension
> > for
> > FireFox to prove that my browser /is/ in fact composing this request in
a
> > syntactically appropriate idiom.  However, in PHP the $_FILES array
comes
> > out of print_r() as just "array ( )" always, and no file is being sent
to
> > the upload directory.
>
> You are sure you've got ENCTYPE="multipart/form-data" right?
>
> > First thought was that the cause was insufficient permissions for the
> > "apache" user:
> > I chmod'ed the directory /var/www/ultmp to 777 and chown'ed it to
apache.
> > I
> > am assuming that the temp directory does not have to be (and really
should
> > not be) a world-readable.  I was able to determine that the cause /is
not/
> > a
> > problem with the permissions of the user "apache" by adding into my PHP
a
> > call to mkdir() which creates a directory off of the directory in my
> > "upload_tmp_dir" directive.  (And verified that the directory does in
fact
> > begin to exist following the script's execution.)
>
> Your /var/www/ultmp directory *DOES* need to be write-able and executable
> by Apache owner, whether through ownership, group, or world permissions,
> almost for sure.
>
> > Second thought was that the cause was with php.ini or http.conf.
> > I have checked apache error_log: nothing.  I tried setting
upload_tmp_dir
> > to
> > (nothing), to "/var/www/ultmp/", and to "/var/www/ultmp"; still nothing.
> > I
> > must admit that I still have not completely determined the cause to be
> > not-apache, but I have no leads except this one in PHP, and my searches
of
> > http.conf yeild no tangible results.
> >
> > I am using a wonderful script
[http://www.epiware.com/scripts/upload.php]
> > to
> > troubleshoot my uploading woes.  I am unable to upload small and large
> > files
> > alike.
> >
> > In my php.ini file, I have the following directives/values
> >  file_uploads = On
> >  upload_tmp_dir = "/var/www/ultmp"
> >  upload_max_file_size = 2M
> >  max_execution_time = 30
> >  post_max_size = 2M
> >
> >
> > But the spark in my curiousity: when I do phpinfo() in my
> > post-action-script, I see for the file_upload directive the "Local
Value"
> > goes to Off.  My guess is that what ever is causing "Local Value" to go
to
> > Off even though "Master Value" is On (I did try restarting the server)
is
> > also causing my $_FILES variable to be empty and my actual file data to
be
> > thrown into the trash.
>
> Aha!
>
> Now we know for sure it *IS* an .htaccess file, or, most unlikely from
> what you say, a setting in httpd.conf that looks like:
> php_flag file_uploads Off
>
> Off may be 0 or False (I think) as well.
>
> It may even be php_value instead of php_flag if that's not a boolean,
> though I think it is.
>
> And in newer versions of PHP, they may have gone with php_value for all
> settings, even boolean ones.
>
> --
> 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