Frågan#1
Hej alla,
Jag har lite kod som ser ut som följande
<?
if (!empty($_POST['valueSub']))
{
// First begin with setting an empty record in the db to get a record id..
$sql="insert into tbl_pic(PicWidth, PicHeight) values(0,0)";
mysql_query($sql) or die("Invalid query: " . mysql_error());
$picID=mysql_insert_id(); // id is picked up here...
echo "+++>".$_FILES['fileUpload']['tmp_name']."<------";
$uploadfile = "img/dbpic/$picID.jpg";
if (move_uploaded_file($_FILES['fileUpload']['tmp_name'], $uploadfile))
{
// the the width and height
$picsize=getimagesize($uploadfile);
$imageWidth=$picsize[0];
$imageHeight=$picsize[1];
// $imageFilename=?????????????????????? <-- Hur?
echo "File is valid, and was successfully uploaded($imageWidth, $imageHeight) from file $imageFilename. ";
// After the name, width and height is piced up, we update the db
$sql="update tbl_pic set PicWidth=$imageWidth, PicHeight=$imageHeight where PicID=$picID";
mysql_query($sql) or die("Invalid query: " . mysql_error()); // After the width and height is piced up, we update the db
}
else
{
echo "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
}
?>
<form enctype=multipart/form-data method=post>
<tr><td>Skicka in bild: </td><td><input type='file' name='fileUpload' size='50'></td></tr>
<tr><td><input type="submit" name="valueSub" value="Skicka in"></td></tr>
</form>
Jag skulle vilja plocka upp filnamnet också av vad filen hette INNAN den hamnade på servern.
Någon som vet hur man gör detta?=)
