mardi 20 janvier 2015

Can't access filename with $_FILES method, PHP


Vote count:

0




I am trying to build a file uploader, with a youtube tutorial that doesn't cover files, and right now I am stuck on the name. Using $_Files returns nothing and I am unsure as to why. :/


I tried to echo it out, but nothing comes back.


Everything else seems to work though.



if(isset($_POST['add'])){

$AddQuery = "INSERT INTO repo (name, id, image, location, partners, description, date) VALUES ('$image_name', '','$_POST[uimage]', '$_POST[ulocation]', '$_POST[upartners]', '$_POST[udescription]', NOW())";
mysql_query($AddQuery, $con);
};

$sql = "SELECT * FROM repo";
$myData = mysql_query($sql,$con);
echo "<table border=1>
<tr>
<th>Image</th>
<th>Name</th>
<th>Location</th>
<th>Partners</th>
<th>Description</th>
<th>Date</th>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<form action=mydata5.php method=post>";
echo "<tr>";

echo "<td>" . "<img src=Assets/Images/" . $record['name'] . " </td>";

echo "<td>" . "<input type=text name=topic value=" . $record['name'] . " </td>";

echo "<td>" . "<input type=text name=name value=" . $record['location'] . " </td>";

echo "<td>" . "<input type=text name=name value=" . $record['partners'] . " </td>";

echo "<td>" . "<input type=text name=description value=" . $record['description'] . " </td>";

echo "<td>" . "<input type=text name=description value=" . $record['date'] . " </td>";

echo "<td>" . "<input type=hidden name=hidden value=" . $record['location'] . " </td>";

echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=mydata5.php method=post>";
echo "<tr>";

echo "<td><input id=uimage type=file name=uimage></td>";

$file = $_FILES['uimage'];
$image_name = mysql_real_escape_string($_FILES['uimage']['name']);


echo "<td><input type=hidden name=uname></td>";
echo "<td><input type=text name=ulocation></td>";
echo "<td><input type=text name=upartners></td>";
echo "<td><input type=text name=udescription></td>";

echo "<td>" . "<input type=submit name=add value=add" . " </td>";
echo "</form>";
echo "</table>";
mysql_close($con);


asked 2 mins ago







Can't access filename with $_FILES method, PHP

Aucun commentaire:

Enregistrer un commentaire