10-03-2008, 10:14 AM
|
#13 (permalink)
|
|
The Wanderer
Join Date: Jan 2008
Location: Leeds, West Yorkshire
Posts: 9
Thanks: 6
|
hey again, sorry to be a pain but i cant seem to get my upload script working here is the script and related form:
Code:
<?php
if(isset($_POST['save']))
{
$title = $_POST['title'];
//$date = date(“Y-m-d”);
// $content = $_POST['content'];
$target_path = "downloads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp'], $target_path))
{
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded";
include '../inc/config.php';
include '../inc/opendb.php';
$query = "INSERT INTO news (title, created_at, filepath) VALUES ('$title', '$date', '$target_path')";
mysql_query($query) or die('Error ,query failed');
include '../inc/closedb.php';
echo "<span class='bold_add'>Article '$title' added</span>";
} else {
echo "There was an error uploading the file, please try again!";
}
}
?>
<form method="post" enctype="multipart/form-data">
<table width="312" border="0" cellpadding="0" cellspacing="0" class="box" align="center">
<tr>
<td width="40" class="white">Title</td>
<td width="272"><input name="title" type="text" class="text" id="title" /></td>
</tr>
<tr>
<td width="40" valign="top" class="white">News</td>
<td><input type="file" class="text" name="uploadedfile" /></td>
</tr>
<tr>
<td width="40"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="right" ><input name="save" type="submit" class="btn" id="save" value="Save Article"></td>
</tr>
</table>
</form>
basically I keep getting the error message regardless of what I try, I dont suppose anyone could tell me where I'm going wrong??
TIA yorkie
__________________
who is general failure? and why is he reading my hard drive?
|
|
|