Jump to content

[SOLVED] Problem with writing data to file using fwrite()


mattachoo

Recommended Posts

Ok, I have a form where the user enters in a bunch of information in a text area box called 'xmldata'  Then, when they submit the form, this is how I process it

<?php

$xmlString = stripslashes(urldecode($_POST['xmldata']));

if (is_null($xmlString)) { 

print "No data was sent"; 

} else { 
$md5 = md5($xmlString);
$filename = "paintings/".$md5.".xml";

$file = fopen($filename, "w+") or die("codename=Cant open XML file"); 

if(!fwrite($file, $xmlString)){ 

	print "Error writing to XML-file"; 

} else {

	require('connect.php');
..................
blahbittyblah
........................
?>

 

Now this code seems to do the trick for me with small amounts of data, but when the file gets too large, I dunno, I think around 25000 characters or something, it cuts it off.  So if the file was 30,000 chars, now the .xml file is 25,000 chars.  You can see how this can be frustrating.  Any ideas guys?  Thanks.

no, it timing out would not be a problem here.  It takes I dont know, 4 seconds to run.  And a max-upload_file is not doing it either.  The file is less than 40 kb, and my max upload is I think 8 mb.  Still any ideas?  I think is happens somewhere in the POST section.  Like even though the text area has 30,000 chars, the form can't hold that much data, and it only holds the max amount when it goes into the $_POST var.  There should be an easier way to do this.  Any help would be much appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.