Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday, April 22, 2008

PHP File Upload Problem Solved!

I finally managed to solve the PHP File Upload Stalemate!

Thanks, in part, to this forum thread... and a bunch of tinkering around in my php.ini file...

I realized that the directives that I modified from:

memory_limit = 8M
post_max_size = 8M
upload_max_filesize = 2M

And changed to:

memory_limit = 8000M
post_max_size = 7000M
upload_max_filesize = 6000M

Was causing me to get the following in my HTTPD/error_log:

[error] PHP Warning: POST Content-Length of 363120480 bytes exceeds the limit of -1249902592 bytes in Unknown on line 0

More specifically it appears that it was the fact that there was just too much of a differential in the post_max_size and the upload_max_filesize that was causing the error...

Which was why PHP would overflow to the negative value... and is considered a feature - though not too many people (probably including myself) would really consider such as a feature!!

I was able to fix the error by modifying my edits of the directives to:

memory_limit = 8000M
post_max_size = 6000M
upload_max_filesize = 6000M

And now it works like a charm!...

So far at least with the large 346.3 M file I tested it with. Hopefully it will still work with larger files!

Now it's pretty much off to the races to finish testing the rest of my project.

One set-back down and very likely several more to go!

Permalink/TrackBack:
http://bvanscoter.blogspot.com/2008/04/php-file-upload-problem-solved.html

Wednesday, April 9, 2008

PHP File Upload Stalemate!

In one of the projects that I have been working on that I've been most hopeful about keeps leading me to one error after another in a stalemate!

This project involves file uploads to a server.

I am doing this with an Apache Server (on Mac OSX) and PHP 5.

I've successfully - or so I think - reconfigured the php.ini file to allow for the capability to upload larger files.

Which is almost identical to this php.ini example, except for the following directives:

memory_limit = 8M
post_max_size = 8M
upload_max_filesize = 2M

Which I've changed to:

memory_limit = 8000M
post_max_size = 7000M
upload_max_filesize = 6000M

And now when I try to upload a large file, which is a .dv video file (one of the larger files I first came across on my computer)... I get the following in my HTTPD/error_log:

[error] PHP Warning: POST Content-Length of 363120480 bytes exceeds the limit of -1249902592 bytes in Unknown on line 0

Now 363120480 bytes is about 346.3 M and is the approximate size of the file I'm trying to upload.

But 1249902592 bytes is 1192 M, and that doesn't match any of the limits I've set in my php.ini file!

Plus 346.3 M < 1192 M!!!

I don't know what's up with the 1249902592 byte-value being negated in the warning - it doesn't make any sense... or is it just a dash in front of the byte-value?

Also, the first time I tried to upload the .dv file the server timed out or something... and got the "this server dropped connection" (or similar) message in Safari.

But that only appeared the first time I tried to upload the file and didn't appear any time after... Which is Totally Bizzare!

I've tried looking in the httpd.conf file for any possible settings that might be hanging things up and countlessly poured over all the directives in the php.ini file... but to no resolve!

Even changing the PHP directive max_execution_time = 30 (because it would normally take about 30 seconds for the upload to fail) to max_execution_time = 300 does nothing... It will still fail after about 30 seconds.

Permalink/TrackBack:
http://bvanscoter.blogspot.com/2008/04/php-file-upload-stalemate.html

Wednesday, October 3, 2007

Pip & My Sequel Trouble


PHP


MySQL

Ok, it's actually PHP 4.4.7 and MySQL 5.0.x!

On my Mac Mini (Intel) I've got Mac OS X 10.4.10 and it comes with it's own Apache Server, in fact all Mac OSX distributions have Apache built in.

I don't remember, but apparently sometime I had installed PHP 4.4.7 and PHP 5 (to use both) I wanted to get MySQL on it because I wanted to start developing some serious web stuff locally...

Since the unfortunate total disappearance a month ago of the last web host I had used... and subsequently lost everything I was working on because I was developing it on their server(s) -- Bad mistake: Not backing anything up just because I didn't have MySQL!

So I got the latest MySQL 5.0.45 release for Mac OS X in the easy installer package format.


PHPMyAdmin

I proceeded to install it and checked to see if it worked with PHP 5 using PHPMyAdmin.

AND... Giddy it worked!

Now I go into the Terminal.app Unix Shell Application and type:

sudo cp /etc/httpd/php4.httpd.conf /etc/httpd/httpd.conf

Switch to PHP 4 and reload the PHPMyAdmin... And I'm Greeted with:

Error

MySQL said:

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

What On Earth!!

I have no idea what that really means...

So I spent the good part of four days researching and trying a bunch of crap to get it to work... by changing the php.ini file by changing the line...

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

TO:

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =/tmp/mysql.sock

Restart the Apache Server and try to reload PHPMyAdmin...

And to no avail I still see...

Error

MySQL said:

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

So after taking a break and coming back I think of linking the mysql socket to where PHP 4 is looking for it....

mysql

MySQL Supportenabled
Active Persistent Links 0
Active Links 0
Client API version 4.1.22
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/mysql/mysql.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient

... In... /var/mysql/mysql.sock

And The info for PHP 5, which works with MySQL is:

mysql

MySQL Supportenabled
Active Persistent Links 0
Active Links 0
Client API version 5.0.19
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/usr/local/php5/include/mysql
MYSQL_LIBS -L/usr/local/php5/lib/mysql -lmysqlclient

So why not create an alias linking /var/mysql/mysql.sock to /tmp/mysql.sock

Not being so fluent in Unix Command-Line stuff, I struggled to figure out how to do this and found this site... Here's what I did (the clean and easy to follow version):

  1. Create 'mysql' folder in /var/
  2. Create A Link Of /tmp/mysql.sock As /var/mysql/mysql.sock
  3. Restart The Apache Server

The Commands:

$ sudo mkdir /var/mysql/
$ sudo ln /tmp/mysql.sock /var/mysql/mysql.sock
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted

And ooh-la-la it works!

Sure it's probably a bit unorthadox, and PHP 4 only has Client API for 4.1.22... but MySQL doesn't change much on the front-end I'm assuming so it should be pretty good.

Everything was confirmed working after creating and editing the same table in MySQL 5 using PHP 4 and PHP 5

Update:

It has come to my attention that though the above may work... it may not work as well as it should...

Because I've run into the instance where the link I would create using $ sudo ln /tmp/mysql.sock /var/mysql/mysql.sock would disappear from /var/mysql/mysql.sock when switching from PHP 4 to PHP 5 and back to PHP 4 again after I restart somewhere in between I think.

I'm not sure where it is breaking down... but there's a couple more robust solutions that I'd suggest... and that is to change the standard link using the ln command to a symbolic link using the ln -s command in terminal.

So now the commands would now be:

$ sudo mkdir /var/mysql/
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted

Or you can do what I did, and just make the folder /var/mysql a symbolic link... which is a little less work:

$ sudo ln -s /tmp/ /var/mysql/
$ sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd gracefully restarted

Note: if you want to do the above there can't be a folder /var/mysql/ already, you'll need to delete it. This can be done using:

$ rm -r /var/mysql/

These commands should work better because of the difference between a hard link and a symbolic link...

A hard link (ln) disappears if the linked-to file disappears... and a symbolic link (ln -s) remains even if the linked-to file disappears and for this situation is what we need since mysql.sock seems to disappear somewhere along the lines of a restart or as described above.

Plus, since symbolic links allow you to have a folder point to another destination folder you can do $ sudo ln -s /tmp/ /var/mysql/

Disclaimer: I take no responsibility for what happens to your system if you use these instructions. Though I have been able to use this methods successfully your results may vary. It is highly advisable you backup any files before changing or modifying them.

Permalink/TrackBack:
http://bvanscoter.blogspot.com/2007/10/pip-my-sequel-trouble.html

 

pages

legal information

privacy policy

We respect your privacy and promise to never sell, barter, share or rent your information to any unauthorized third party. By providing your contact information you are also requesting and agreeing to receive important information about future events. (You may unsubscribe at any time.)
view full privacy policy here

certification of authenticity

I certify that the information contained on this site is true and complete to the best of my knowledge and understanding, any discrepencies will be governed by the terms of use.

terms of use

Everything we provide is provided "as is" including but not limited to the implied warranties of merchantability or fitness for a particular purpose, without any promise or guarantee of earnings. All forward looking statements on any of our materials are intended as an expression our opinion and will not responsible for any incidental or consequential damages from your actions.
view official terms of use