Connecting Tech Pros Worldwide Help | Site Map

Upload problems

  #1  
Old April 11th, 2007, 12:15 PM
Nosferatum
Guest
 
Posts: n/a
I intend to upload documents (file_up), categorize them in 4 main
categories (k_cat), have additional sub-categories (lec_cat) just for
querying and getting sub-categorized output of the files when listed
with date (dato_inn) and the submitters details "uploaded_by".

But my script will not work. Anyone clever out there seeing what's
wrong?

This is my upload form, the script at the bottom:

<form enctype="multipart/form-data" id="uploadform" action="added.php"
method="post" name="uploadform">
<table width="90%" border="0" cellspacing="2" cellpadding="0"><tr><td
width = "150"><div align="right">
<label for="fil">Choose file to upload: </label>
</div></td>
<td><input id="file_up" name="file_up" type="file" size="50" value=""
maxlength="255"></td></tr><tr><td width = "150"><div align="right">
<label for="k_cat">Choose main category: </label>
</div></td>
<td><select name="k_cat" id="k_cat">
<option value="Category_1">Category_1</option>
<option value="Category_2">Category_2</option>
<option value="Category_3">Category_3</option>
<option value="Category_4">Category_4</option>
</select>
</td></tr><tr><td width = "150"><div align="right">
<label for="lev_cat">Choose sub category </label>
</div></td>
<td><select name="lev_cat" id="lev_cat">
<option value="Category_1_Sub_1">Category_1_Sub_1</option>
<option value="Category_1_Sub_2">Category_1_Sub_2</option>
<option value="Category_1_Sub_3">Category_1_Sub_3</option>
<option value="Category_1_Sub_4">Category_1_Sub_4</option>
<option value="Category_2_Sub_1">Category_2_Sub_1</option>
<option value="Category_2_Sub_2">Category_2_Sub_2</option>
<option value="Category_2_Sub_3">Category_2_Sub_3</option>
<option value="Category_2_Sub_4">Category_3_Sub_4</option>
</select></td></tr><tr><td width = "150"><div align="right">
<label for="dato_inn">Date uploaded</label>
</div></td>
<td><input id="dato_inn" name="dato_inn" type="text" size="25"
value="" maxlength="255"></td></tr><tr><td width = "150"><div
align="right">
<label for="uploaded_by">Uploaded by:</label>
</div></td>
<td><input id="uploaded_by" name="uploaded_by" type="text" size="25"
value="" maxlength="255"></td></tr><tr><td width="150"></td><td>
<input type="submit" name="submitButtonName" value="Add file and entry
to DB"></td>
</tr></table>
</form>


<?php
//this is added.php

include("connect.php");
$file_up = $_POST['file_up'];
$k_cat = $_POST['k_cat'];
$lev_cat = $_POST['lev_cat'];
$dato_inn = $_POST['dato_inn'];
$uploaded_by = $_POST['uploaded_by'];


if $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_1' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_1/{$_FILES['file_up'] ['name']}")
}

elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_2' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_2/{$_FILES['file_up'] ['name']}")
}
elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_3' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_3/{$_FILES['file_up'] ['name']}")
}
elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_4' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_4/{$_FILES['file_up'] ['name']}")
}


$query = "INSERT INTO lev_database (id, file_up, k_cat, lev_cat,
dato_inn, uploaded_by)
VALUES ('', '$file_up', '$k_cat', '$lev_cat', '$dato_inn',
'$uploaded_by')";

$results = mysql_query($query) or die
("Could not execute query : $query." . mysql_error());

if ($results)
{
echo "Details added.";
}
mysql_close();
?>

  #2  
Old April 11th, 2007, 01:35 PM
Steve Belanger
Guest
 
Posts: n/a

re: Upload problems


could be a lot of things,

mostly when such a thing happen in my case it's a permission problem, make
sure that the directory where you upload the files can be written to by PHP.

another less common case would be that your host disabled the use of the
functions used to take an uploaded file and copy it somewhere else.

Hope this helps.

"Nosferatum" <John.Olav.O@gmail.comwrote in message
news:1176289643.591928.253800@q75g2000hsh.googlegr oups.com...
Quote:
>I intend to upload documents (file_up), categorize them in 4 main
categories (k_cat), have additional sub-categories (lec_cat) just for
querying and getting sub-categorized output of the files when listed
with date (dato_inn) and the submitters details "uploaded_by".
>
But my script will not work. Anyone clever out there seeing what's
wrong?
>
This is my upload form, the script at the bottom:
>
<form enctype="multipart/form-data" id="uploadform" action="added.php"
method="post" name="uploadform">
<table width="90%" border="0" cellspacing="2" cellpadding="0"><tr><td
width = "150"><div align="right">
<label for="fil">Choose file to upload: </label>
</div></td>
<td><input id="file_up" name="file_up" type="file" size="50" value=""
maxlength="255"></td></tr><tr><td width = "150"><div align="right">
<label for="k_cat">Choose main category: </label>
</div></td>
<td><select name="k_cat" id="k_cat">
<option value="Category_1">Category_1</option>
<option value="Category_2">Category_2</option>
<option value="Category_3">Category_3</option>
<option value="Category_4">Category_4</option>
</select>
</td></tr><tr><td width = "150"><div align="right">
<label for="lev_cat">Choose sub category </label>
</div></td>
<td><select name="lev_cat" id="lev_cat">
<option value="Category_1_Sub_1">Category_1_Sub_1</option>
<option value="Category_1_Sub_2">Category_1_Sub_2</option>
<option value="Category_1_Sub_3">Category_1_Sub_3</option>
<option value="Category_1_Sub_4">Category_1_Sub_4</option>
<option value="Category_2_Sub_1">Category_2_Sub_1</option>
<option value="Category_2_Sub_2">Category_2_Sub_2</option>
<option value="Category_2_Sub_3">Category_2_Sub_3</option>
<option value="Category_2_Sub_4">Category_3_Sub_4</option>
</select></td></tr><tr><td width = "150"><div align="right">
<label for="dato_inn">Date uploaded</label>
</div></td>
<td><input id="dato_inn" name="dato_inn" type="text" size="25"
value="" maxlength="255"></td></tr><tr><td width = "150"><div
align="right">
<label for="uploaded_by">Uploaded by:</label>
</div></td>
<td><input id="uploaded_by" name="uploaded_by" type="text" size="25"
value="" maxlength="255"></td></tr><tr><td width="150"></td><td>
<input type="submit" name="submitButtonName" value="Add file and entry
to DB"></td>
</tr></table>
</form>
>
>
<?php
//this is added.php
>
include("connect.php");
$file_up = $_POST['file_up'];
$k_cat = $_POST['k_cat'];
$lev_cat = $_POST['lev_cat'];
$dato_inn = $_POST['dato_inn'];
$uploaded_by = $_POST['uploaded_by'];
>
>
if $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_1' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_1/{$_FILES['file_up'] ['name']}")
}
>
elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_2' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_2/{$_FILES['file_up'] ['name']}")
}
elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_3' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_3/{$_FILES['file_up'] ['name']}")
}
elseif $_POST['file_up'] ==<1 & $_POST['k_cat']=='category_4' {
move_uploaded_file ($_FILES['file_up'] ['tmp_name'],
"../uploads/category_4/{$_FILES['file_up'] ['name']}")
}
>
>
$query = "INSERT INTO lev_database (id, file_up, k_cat, lev_cat,
dato_inn, uploaded_by)
VALUES ('', '$file_up', '$k_cat', '$lev_cat', '$dato_inn',
'$uploaded_by')";
>
$results = mysql_query($query) or die
("Could not execute query : $query." . mysql_error());
>
if ($results)
{
echo "Details added.";
}
mysql_close();
?>
>

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Upload Problems xoise answers 2 July 7th, 2008 05:11 PM
file upload problems Arthur Jacobs answers 5 January 17th, 2007 09:35 PM
file upload problems jmlin84@gmail.com answers 3 September 29th, 2005 09:25 AM
Php upload problems Chris answers 0 July 16th, 2005 11:48 PM