Problem
I got this cool tool from 'Howtos' posted by ATLI, but I'm having trouble on posting or uploading files bigger than 15000KB although I create the table field into a 'LongBlob'. Is there any other way to maximize the the field? Script -
<?php
-
# Check if a file has been uploaded
-
if(isset($_FILES['uploaded_file']))
-
{
-
# Make sure the file was sent without errors
-
if($_FILES['uploaded_file']['error'] == 0)
-
{
-
# Connect to the database
-
$dbLink = mysql_connect("localhost","user", "password")
-
or die("Error! Failed to connect to the MySQL server!");
-
mysql_select_db("tablename", $dbLink)
-
or die("Error! Failed to select a database!");
-
-
# Gather all required data
-
$name = mysql_real_escape_string($_FILES['uploaded_file']['name'], $dbLink);
-
$mime = mysql_real_escape_string($_FILES['uploaded_file']['type'], $dbLink);
-
$size = $_FILES['uploaded_file']['size'];
-
$author = $_POST['author'];
-
$requestor = $_POST['requestor'];
-
$description = $_POST['description'];
-
$data = mysql_real_escape_string(file_get_contents($_FILES ['uploaded_file']['tmp_name']), $dbLink);
-
-
# Create the SQL query
-
$query = "
-
INSERT INTO fileStorage (
-
FileName, FileMime, FileSize, FileData, Created, Author,
-
)
-
VALUES (
-
'{$name}', '{$mime}', {$size}, '{$data}', NOW(), '$author'
-
)";
-
-
# Execute the query
-
$result = mysql_query($query, $dbLink);
-
-
# Check if it was successfull
-
if($result)
-
{
-
echo "Success! Your file was successfully added!";
-
echo "$author";
-
}
-
else
-
{
-
echo "Error! Failed to insert the file";
-
echo "<pre>". mysql_error($dbLink) ."</pre>";
-
}
-
}
-
else
-
{
-
echo "Error!
-
An error accured while the file was being uploaded.
-
Error code: ". $_FILES['uploaded_file']['error'];
-
}
-
-
# Close the mysql connection
-
mysql_close($dbLink);
-
}
-
else
-
{
-
echo "Error! A file was not sent!";
-
}
-
-
# Echo a link back to the mail page
-
echo '<p>Click <a href="cmr.php">here</a> to go back</p>';
-
?>
Result
Error! An error accured while the file was being uploaded. Error code: 1
or
Error! Failed to insert the file
Got a packet bigger than 'max_allowed_packet'
6 3044 Atli 5,058
Expert 4TB
Hi.
The first error there would indicate a problem with your PHP configuration.
The error codes for file uploads are explained here.
Error code 1 means "The uploaded file exceeds the upload_max_filesize directive in php.ini. "
Meaning that to fix this problem, you would have to increase the upload_max_filesize directive. (You may also want to take a look at the post_max_size directive).
The second error you posted would probably be a problem with your MySQL configuration. I would start by changing the max_allowed_packet directive in the my.cnf file on your server.
Hi Atli,
Still I'm having same problem although I adjusted the php.in and my.cnf below and by the way I'm running my mysql server on a novell box. my.cnf
[client]
user=root
[mysqld]
default-character-set=latin1
language=english
bind-address=XX.XX.XX.X
port=3306
datadir=VOL3:/MySQL/Data
skip-locking
skip-innodb
max_allowed_packet=25M PHP.INI
; Maximum size of POST data that PHP will accept.
post_max_size = 25M
; Maximum allowed size for uploaded files.
upload_max_filesize = 25M
Atli 5,058
Expert 4TB
That's weird.
Using those config files, neither of those error should appear.
Did you restart Apache after the changes?
Don't know Novell very well, but you could also try rebooting the server.
Is it possible that you are editing the wrong php.ini file? (I've done that a couple of times myself)
Take a look at the file indicated in the phpinfo() output, see if they match.
Hi Atli,
Looks like my.cnf file didn't read at all when I view this command inside mysql
command:
show variables like 'max_allowed_packet'; result:
variable_name value
max_allowed_packet 1048576 questions
my.cnf file is located under etc folder where it should be lying?
MB
Atli 5,058
Expert 4TB
On my Ubuntu server the my.cnf file is under /etc/mysql/, although that may well be different for you.
Make sure you restart the mysql server to after editing the file.
Hi Atli,
You were right it's all about restarting the novell box not just re-starting the apache and mysql.
You rock!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dickiedyce |
last post by:
Hi there.
I've spent the weekend getting ever more frustrated, trying to get an
upload file function working on a website.
The site is hosted by a company called oneandone. They're using PHP...
|
by: Kevin Ollivier |
last post by:
Hi all,
I've come across a problem that has me stumped, and I thought I'd send
a message to the gurus to see if this makes sense to anyone else. =)
Basically, I'm trying to upload a series of...
|
by: Ron Brennan |
last post by:
Good afternoon.
The entire task that I'm trying to achieve is to allow a user to browse and
upload multiple files simultaneously, hiding the Browse button of <input>
tags of type="file" and...
|
by: Sky Sigal |
last post by:
I have created an IHttpHandler that waits for uploads as attachments for a
webmail interface, and saves it to a directory that is defined in
config.xml.
My question is the following:
assuming...
|
by: Raj |
last post by:
Hello,
I am planning to provide the Pause/Resume while uploading files.
Our site is using both java applet and activex to do this.
The list of selected files will be stored in an encrypted...
|
by: Atli |
last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t.
In situations where your PHP application...
|
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= |
last post by:
jodleren escribió:
I haven't found the PHP manual page where such feature is documented but
a few tests have shown that this behaviour changes depending on the
charset parameter of the...
|
by: =?Utf-8?B?RGFu?= |
last post by:
MS won't seem to let me reply to my old post, so I created a new one.
The error occurs in all browsers. It's definitely a server issue, not client.
The server is not proxied in any way.
I tried...
|
by: muziburrehaman |
last post by:
i am looking for code in php to upload the 1 gb files. any one can
please help me by sending the code....
|
by: LoriFranklin |
last post by:
I'm a bit of a newbie here. I've learned a lot from reading the posts you all have here. I need some help uploading files using an asp form.
I am using some code that I found from Jacob at...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |