Ok, first off let me thank everyone for thier continued support via this forum.
Second, I have this script below which has two problems.
The ini_set isnt working. I am trying to set it to 40MB via the script, and a php.ini file in all of my directories. It just wonr change! Grr...
And...When running ht epage below, I get an error saying that the used command is not vaild for my version.
I have php 4.3.8 and MySQL 4.0.2-Standard
Please help! I have been trying to get this done for some time now. 🙁
<?php
session_start();
// if session is not registered redirect to login
if (!session_is_registered("admin"))
{
header("Location: login.php");
}
ini_set('upload_max_filesize', '40M');
ini_set('post_max_size', '40M');
include_once ("config.php");
include_once ("settings.inc.php");
include_once ("../images/makethumb.txt");
include_once ("header.inc.php");
if($_POST['submit']){
// $userfile is where file went on webserver
$userfile = $HTTP_POST_FILES['userfile']['tmp_name'];
// $userfile_name is original file name
$userfile_name = $HTTP_POST_FILES['userfile']['name'];
// $userfile_size is size in bytes
$userfile_size = $HTTP_POST_FILES['userfile']['size'];
// $userfile_type is mime type e.g. image/gif
$userfile_type = $HTTP_POST_FILES['userfile']['type'];
// $userfile_error is any error encountered
$userfile_error = $HTTP_POST_FILES['userfile']['error'];
// userfile_error was introduced at PHP 4.2.0
// use this code with newer versions
if ($userfile_error > 0)
{
echo 'Problem: ';
switch ($userfile_error)
{
case 1: echo 'File exceeded upload_max_filesize of '.ini_get('upload_max_filesize'); break;
case 2: echo 'File exceeded max_file_size'; break;
case 3: echo 'File only partially uploaded'; break;
case 4: echo 'No file uploaded'; break;
}
exit;
}
// end of code for 4.2.0
// put the file where we'd like it
$upfile = $site_dir.'/wm/'.$userfile_name;
$realpath = realpath( $upfile );
// is_uploaded_file and move_uploaded_file added at version 4.0.3
if (is_uploaded_file($userfile))
{
if (!move_uploaded_file($userfile, $upfile))
{
echo 'Problem: Could not move file to destination directory';
exit;
}
}
else
{
echo 'Problem: Possible file upload attack. Filename: '.$userfile_name;
exit;
}
echo ' <br> File uploaded successfully<br /><br />';
system("chmod 777" . $realpath );
mysql_query("LOAD DATA LOCAL INFILE '" . $realpath . "' INTO TABLE ".$prefix."store_wholesale fields terminated by '\t' lines terminated by '\n'");
if (!$mysql) {
die('Invalid query: ' . mysql_error());
} else {
echo '<h1>Database Updated</h1>';
}
mysql_close($mysql);
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table align="center" border="0">
<tr><td>Select file: <input type="file" name="userfile" size="24" class="file"><input type="hidden" name="MAX_FILE_SIZE" value="40000000"> <input type="submit" name="submit" class="submit" value=" Go! "></td></tr>
</table>
</form>
<?php
}
?>