Advertisement
Advertisement
| 03.07.2008 at 03:19AM PST, ID: 23222532 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: |
=========
index.php
=========
<?php
if ($id) {
$sql = "SELECT * FROM helpdesk_data WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$attachment = $myrow["attachment"];
echo "<input type='hidden' name='id' value='$id''>";
}
echo "<form enctype='multipart/form-data' action='process_form.php' method='post'>
Upload new file: <input type='file' name='attachment'><br>
Attached: <a target='_blank' href='/files/$attachment'>$attachment</a><br>
<input name='new' type='submit' value='New Record'>
<input name='update' type='submit' value='Update Record'>
</form>";
?>
================
process_form.php
================
<?php
@$new = $_POST['new'];
@$update = $_POST['update'];
// Receiving variables
@$attachment_Name = $_FILES['attachment']['name'];
@$attachment_Size = $_FILES['attachment']['size'];
@$attachment_Temp = $_FILES['attachment']['tmp_name'];
@$attachment_Mime_Type = $_FILES['attachment']['type'];
function RecursiveMkdir($path){
if (!file_exists($path)){
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if( $attachment_Size == 0){}
else{
$uploadDir = "./files/";
$uploadFile = "./files/".$attachment_Name ;
$fileExt = substr(strrchr($attachment_Name, "."), 1);
$randName = md5(rand() * time());{
@chmod(dirname($uploadFile), 0777);
}
$filePath = $uploadDir . $randName . '.' . $fileExt;
@move_uploaded_file( $attachment_Temp , $filePath);
chmod($filePath, 0644);
$attachment_URL = "http://files/".$randName . '.' . $fileExt;
$md5Name = $randName . '.' . $fileExt;
}
if($new =='New Record'){
//saving record to MySQL database
@$pfw_strQuery = "INSERT INTO `helpdesk_data`(`attachment`)VALUES (\"$md5Name\")" ;
@$pfw_host = "localhost";
@$pfw_user = "root";
@$pfw_pw = "password";
@$pfw_db = "helpdesk";
$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
if (!$pfw_link){
die('Could not connect: ' . mysql_error());
}
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
if (!$pfw_db_selected){
die ('Can not use $pfw_db : ' . mysql_error());
}
//insert new record
$pfw_result = mysql_query($pfw_strQuery);
if (!$pfw_result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($pfw_link);
}
if($update =='Update Record'){
//updating record in MySQL database
@$pfw_strQuery = "UPDATE helpdesk_data SET attachment = \"$md5name\" WHERE id = \"$id\"";
@$pfw_host = "localhost";
@$pfw_user = "root";
@$pfw_pw = "Ae3B7DdG2";
@$pfw_db = "helpdesk";
$pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw);
if (!$pfw_link){
die('Could not connect: ' . mysql_error());
}
$pfw_db_selected = mysql_select_db($pfw_db, $pfw_link);
if (!$pfw_db_selected){
die ('Can not use $pfw_db : ' . mysql_error());
}
//updating record
$pfw_result = mysql_query($pfw_strQuery);
if (!$pfw_result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($pfw_link);
}
header('Location: index.php');
die();
?>
|