I am using upload.html to upload files
<html>
<body>
<h3>File Upload</h3>
Select a file to upload:<br/>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="100">
<br/>
<input type="submit" value="Upload File">
</form>
</body>
</html>
upload.php is here:
<?php
error_reporting(E_ALL);
if($file_name !="")
{
copy("$file","/path/$file_name")
or die("Could not copy file");
///usr/local/apache_1.3.33/$file_name
}
else
{
die("no file specified");
}
?>
<html>
<head><title>Upload Complete</title></head>
<body>
<h3>Upload Succceeded</h3>
<ul>
<li>Sent: <?php echo "$file_name"; ?>
<li>Size: <?php echo "$file_size"; ?> bytes
<li>Type: <?php echo "$file_type"; ?>
</ul>
<a href="<?php echo "$file_name" ?>">Click to view file</a>
</body>
</html>
This thing works for uploading most of the files ... but is unable to upload file like this one:
<?php
require('db_connect.php'); // database connect script.
?>
<html>
<head>
<title>add to test1</title>
</head>
<body>
<?php
if (isset($_POST['submit']))
{ // if form has been submitted
/* check they filled in what they supposed to,
passwords matched, username
isn't already taken, etc. */
if (!$_POST['name'])
{
die('You did not fill in a required field.');
}
// check if username exists in database.
if (!get_magic_quotes_gpc())
{
$_POST['name'] = addslashes($_POST['name']);
}
$name_check = $db_object->query("SELECT name FROM test1 WHERE name = '".$_POST['name']."'");
if (DB::isError($name_check))
{
die($name_check->getMessage());
}
$name_checkk = $name_check->numRows();
if ($name_checkk != 0)
{
die('Sorry, the name: <strong>'.$_POST['name'].'</strong> is already taken, please pick another one.');
}
// no HTML tags in username, website, location, password
$_POST['name'] = strip_tags($_POST['name']);
$_POST['website'] = strip_tags($_POST['website']);
/* the rest of the information is optional, the only thing we need to
check is if they submitted a website,
and if so, check the format is ok. */
if ($_POST['website'] != '' & !preg_match("/^(http|ftp):\/\//", $_POST['website']))
{
$_POST['website'] = 'http://'.$_POST['website'];
}
if (!get_magic_quotes_gpc())
{
$_POST['website'] = addslashes($_POST['website']);
}
$regdate = date('M d, Y');
error_reporting(E_ALL);
$insert = "INSERT INTO test1 (
// name,
// website,
regdate)
VALUES (
// '".$_POST['name']."',
// '".$_POST['website']."',
{'$regdate'})";
$add_member = $db_object->query($insert);
if (DB::isError($add_member))
{
die($add_member->getMessage());
}
$db_object->disconnect();
?>
<h1>Added to test1</h1>
<p>
Thank you, your information has been added to the database,
you may now <a href="login.php" title="Login">log in</a>.
</p>
<?php
}
else
{ // if form hasn't been submitted
?>
<h1>Test1</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Name*:</td><td>
<input type="text" name="name" maxlength="60">
</td></tr>
<tr><td>Website:</td><td>
<input type="text" name="website" maxlength="150">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Sign Up">
</td></tr>
</table>
</form>
<?php
}
?>
</body>
</html>
why is it like that?