Iam trying to upload a XML file to update my SQL database but have problems when the file reach a certain size...
I have been told that you have to check the upload_max_filesize = 10M in the php.ini but cannot find it.
Do i have to create a php.ini file ? if so, where should i place it ? In the same location as the php program code ?
thanks.
php.ini file location
Moderator: General Moderators
Re: php.ini file location
How are you uploading it? Have you tried ini_set()?
-
grabber_grabbs
- Forum Commoner
- Posts: 60
- Joined: Mon Oct 10, 2011 6:13 pm
Re: php.ini file location
Thanks Celauran for helping here.
not sure i understand your question, but here is the answer.
ini_set() ? i will do some reading on it for sure...
I have a html form <form enctype="multipart/form-data" action="import.php" method="post">
in my import.php :
i first check the file type, to be sure its a xml file, then if that condition pass, i do the following :
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$PRODNO = "";
$DESCSHORT = "";
$DEPT = "";
$DESCLONG = "";
$PRIX = "";
$UNITEVTE = "";
$STOCK = "";
$DATEDEBUT = "";
$TVH = "";
etc etc...
if i try an excell file with 1000 row, it pass ok, but over this, i have a message telling me like cannot find file.xml (not the exact message here)
So it has to be related to the size of the file. I did my homework tried to find info over the internet and got lots of info, but i cannot find where i do find that php.ini file... is it a file i have to create to override the php default value of the server. I read somewhere that the default value for upload_max_filesize is 2M. If i look at my file, it is 3.2M approx.
I have an account with ipage.com and went there and tried to find an administrative area, or a admin place where i would select/update these php value with no success.
Now since i have you here,
i will take the chance to ask you more questions... if you agree.
The way i am updating my database file now , i first truncate the SQL table to delete all the records, and then i do a SQL Insert for each record found in my XML file. Right now i am just developping the code, so nobody is surfing my website, so there is no problem deleting the entire database and updating it.... but eventually it will be different.... it is strongly possible that some custumer will be browsing my website while i will be interested into updating the master database.... so do i think right here saying that my first approch to update the file is not the best...
Maybe i shoud take a different approch like : first make a query WHERE $itemfromXML = itemfieldinSQL, then, do a $record =mysql_num_rows($sql) , so if $record is >0 i would then $query="UPDATE mastersql SET or if $record is = 0 then i would make a $query = "INSERT INTO mastersql
is the second approch the one i shoud take if i do want to update my master file without having to logg everybody out... Maybe i do too much of thinking here and making a truncate of the master and then updating it is the fastest way to do it...
If you have time to share here i would appreciate to know how you would approch this master file update.
thanks again.
not sure i understand your question, but here is the answer.
ini_set() ? i will do some reading on it for sure...
I have a html form <form enctype="multipart/form-data" action="import.php" method="post">
in my import.php :
i first check the file type, to be sure its a xml file, then if that condition pass, i do the following :
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$PRODNO = "";
$DESCSHORT = "";
$DEPT = "";
$DESCLONG = "";
$PRIX = "";
$UNITEVTE = "";
$STOCK = "";
$DATEDEBUT = "";
$TVH = "";
etc etc...
if i try an excell file with 1000 row, it pass ok, but over this, i have a message telling me like cannot find file.xml (not the exact message here)
So it has to be related to the size of the file. I did my homework tried to find info over the internet and got lots of info, but i cannot find where i do find that php.ini file... is it a file i have to create to override the php default value of the server. I read somewhere that the default value for upload_max_filesize is 2M. If i look at my file, it is 3.2M approx.
I have an account with ipage.com and went there and tried to find an administrative area, or a admin place where i would select/update these php value with no success.
Now since i have you here,
The way i am updating my database file now , i first truncate the SQL table to delete all the records, and then i do a SQL Insert for each record found in my XML file. Right now i am just developping the code, so nobody is surfing my website, so there is no problem deleting the entire database and updating it.... but eventually it will be different.... it is strongly possible that some custumer will be browsing my website while i will be interested into updating the master database.... so do i think right here saying that my first approch to update the file is not the best...
Maybe i shoud take a different approch like : first make a query WHERE $itemfromXML = itemfieldinSQL, then, do a $record =mysql_num_rows($sql) , so if $record is >0 i would then $query="UPDATE mastersql SET or if $record is = 0 then i would make a $query = "INSERT INTO mastersql
is the second approch the one i shoud take if i do want to update my master file without having to logg everybody out... Maybe i do too much of thinking here and making a truncate of the master and then updating it is the fastest way to do it...
If you have time to share here i would appreciate to know how you would approch this master file update.
thanks again.
Re: php.ini file location
I can't help but think it would be easier to parse the XML file locally, write a .sql file, take the site offline for maintenance for a few minutes, and feed the .sql file to phpMyAdmin. Alternately, rather than uploading the file through a form, you FTP it and then read it in through fopen or file_get_contents.
-
grabber_grabbs
- Forum Commoner
- Posts: 60
- Joined: Mon Oct 10, 2011 6:13 pm
Re: php.ini file location
$maxfilesize = ini_get('max_upload_filesize');
echo $maxfilesize;
if (!ini_get('max_upload_filesize')) {
ini_set('max_upload_filesize', 8388608);
}
echo ini_get('max_upload_filesize');
?>
i get 0.... could this command not compatible with the server i use ?
echo $maxfilesize;
if (!ini_get('max_upload_filesize')) {
ini_set('max_upload_filesize', 8388608);
}
echo ini_get('max_upload_filesize');
?>
i get 0.... could this command not compatible with the server i use ?
Re: php.ini file location
You can get the upload_max_filesize from phpinfo()