Jump to content

Recommended Posts

Hi there, i am trying to store some file data in MySQL, the data is around 1Mb in size, everytime i click to submit i get this error

The requested URL's length exceeds the capacity limit for this server

 

The MySQL field is set as BLOB and here is my php code for the action

 

<?php
        $xml = $_POST['xml'];

        if(isset($_POST['xml'])) {
        $xml = ('SWFT' . base64_encode(gzcompress("$xml")));
        $xml = substr($xml, 0);
        // UPDATE the database with the newly generated and encoded xml.gz file
mysql_query("UPDATE `users` SET xml='$xml' WHERE id='$_SESSION[user_id]'") 
or die(mysql_error());
}
?>

 

My question is seeing as i get the URI error with this method, how can i get the code to compress the xml to xml.gz and store it into the database as a gzipped file, any ideas? Im new to .php so any replies would have to be in a "php for dummies" kind of format, also my attached code is probably wierd so any tips on making it better would be appreciated, thanks

Link to comment
https://forums.phpfreaks.com/topic/201248-storing-file-data-in-mysql/
Share on other sites

Its not mysql failing its the fact yuour trying to send a huge amount of data through a simple form field (textarea).

 

Upload the file to the server, then read the temporary file and insert those contents.

 

Have a look at (google): PHP Uploading Files (Lots of tutorials for Newcomers to PHP).

 

-cb-

The error has nothing to do with the php code.

 

It is likely your form is using the get method, rather than the post method.

 

What is your form code?

 

Told you i was a newbie..lol,

i didnt put a form method in  :-[, works ok now with post, thanks for pointing me in the right direction

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.