|
 |
|
รบกวนช่วยดูหน่อยครับมัน insert เข้า sql ไม่ได้อ่ะคับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
$form = "<form action='index.php' method='post' enctype='multipart/form-data'>
<table>
<tr>
<td>Title:</td>
<td><input type='text' name='title'/></td>
</tr>
<tr>
<td>Description :</td>
<td><textarea name='description' cols='30'></textarea></td>
</tr>
<td></td>
<td><input type='file' name='myfile'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submitbutton' value='upload'/></td>
</tr>
</table>
</form>";
if($_POST['submitbutton'])
{
$title = $_POST['title'];
$title = $_POST['description'];
$name = $_FILES['myfile']['name'];
$type = $_FILES['myfile']['type'];
$size = $_FILES['myfile']['size'];
$tmpname = $_FILES['myfile']['tmp_name'];
$ext = substr($name, substr($name, '.'));
if ($name)
{
if($title && $description)
{
require("connect/connect.php");
$date = date("m-d-y");
$charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
$length = 15;
for ($i = 0; $i <= $length; $i++)
{
$rand = rand() % strlen($charset);
$tmp = substr($charset, $rand, 1);
$code .= $tmp;
}
while ($numrows != 0)
{
for ($i = 0; $i <= $length; $i++)
{
$rand = rand() % strlen($charset);
$tmp = substr($charset, $rand, 1);
$code .= $tmp;
}
$query = mysql_query("SELECT token FROM file WHERE token='$code'");
$numrows = mysql_num_rows($query);
}
mkdir("MyFiles/$code/", 777);
move_uploaded_file($tmpname, "MyFiles/$code/"."$name");
$query = mysql_query("INSERT INTO file VALUES ('', '$title' , '$code' ,'$description' ,'$date')");
header("location:download.php?token=$code");
}
else
echo "You did fill in the form completly.";
}
else
echo "You did not select a File.";
}
else
echo "$form";
?>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-10-29 20:53:56 |
By :
nukedonut1 |
View :
866 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 04
|