uploading woes
Posted: Tue Jun 03, 2003 11:35 pm
I am trying to write a simple uploading script from a form.
Here is the form code
Here is the uploading script
Here is what the echos give me
Any ideas what I am missing???????
Here is the form code
Code: Select all
function gallery_newpic()
{
$sdate = date('Y-m-d', strtotime('now'));
$edate = date('Y-m-d', strtotime('12 weeks from '.$sdate));
$query = "SELECT picnum FROM gallery WHERE expdate <= '".$sdate."'";
$result = query_db($query);
$num_rows = mysql_num_rows($result);
if ($num_rows > 0)
{
$pc = mysql_fetch_array($result);
$action_url = "gallery_fns.php?page=upd";
}
else
$action_url = "gallery_fns.php?page=add1";
?>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><font size="5"><b>Picture Gallery Entry</b></font></td>
</tr>
<tr>
<td><font size="2">Choose File: </font></td>
<td><form method="post" action="gallery_fns.php?page=add1" ENCTYPE="multipart/form-data"><INPUT TYPE="file" NAME="pic"></td>
</tr>
<TR>
<TD COLSPAN="2"><INPUT VALUE="Submit" TYPE="submit"></form></TD>
</TR>
</TABLE>
</form>
<?
}Code: Select all
function gallery_upload1($form_vars, $mode, $id="")
{
$uploaddir = '/usr/home/christschurch/gallery';
echo 'fn='.$_FILESї'userfile']ї'name'].'<br>';
echo 'fn1='.$form_varsї'userfile']ї'name'].'<br>';
echo 'h='.$HTTP_POST_FILESї'userfile']ї'name'].'<br>';
echo 'h1='.$HTTP_POST_FILESї'userfile']ї'tmp_name'].'<br>';
if (move_uploaded_file($_FILESї'userfile']ї'tmp_name'], $uploaddir . $_FILESї'userfile']ї'name']))
{
print "File is valid, and was successfully uploaded. Here's some more debugging info:\n";
print_r($_FILES);
}
$sdate = date('Y-m-d', strtotime('now'));
$edate = date('Y-m-d', strtotime('+3 months'));
if ($mode == "u")
{
$query = "UPDATE gallery SET ".
"entrydate = '".$sdate."', ".
"expdate = '".$edate."', ".
"image = '".$_FILESї'userfile']ї'name']."' ".
"WHERE picnum = ". $form_varsї'pid'];
}
if ($mode == "n")
{
$query = "INSERT INTO gallery VALUES(".
"NULL, ".
"'".$sdate."', ".
"'".$edate."', ".
"'".$_FILESї'userfile']ї'name']."') ";
}
echo $query.'<br>';
$result = query_db($query);
}Code: Select all
fn=
fn1=
h=
h1=
INSERT INTO gallery VALUES(NULL, '2003-06-03', '2003-09-03', '')