stiffy
Erfahrenes Mitglied
Hi,
folgendes Skript läd mir zwar meine Dateien in den richtigen Ordner, allerdings schreibt es nur das Datum in die Tabelle. Irgendwelche Vorschläge ich bin echt am Verzweifeln.
Danke im Vorraus,
stiff
folgendes Skript läd mir zwar meine Dateien in den richtigen Ordner, allerdings schreibt es nur das Datum in die Tabelle. Irgendwelche Vorschläge ich bin echt am Verzweifeln.
PHP:
<?php
//edit this
include("sqldata.php");
$upload_dir = "../upload/"; //upload folder..chmod to 777
$_i = "3"; //number of files to upload at one time
//end edit
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . 10000*1024 , "'>";
echo "Text:<br><br><br><textarea name=text rows=25 cols=100></textarea><br><br>";
echo "Choose your file(s): <br>";
//show number of files to select
For($i=0; $i <= $_i-1;$i++)
{
echo "<input name='file" . $i . "' type='file'><br>";
}
echo "<br><br><input type='submit'>";
echo "</form>";
if($_GET['do'] == 'upload')
{
mysql_connect($sqlhost, $sqluser, $sqlpass);
mysql_select_db($sqlbase);
$date = date("j.n.Y");
// $text = $_GET['text'];
mysql_query("INSERT INTO news (date, text) VALUES ('$date', '$text')");
//upload all the fields until done
For($i=0; $i <= $_i-1; $i++)
{
//create a random number
$_random = rand(1, 1000000);
//file with the upload folder
$target_path = $upload_dir . $_random . basename($_FILES['file' . $i]['name']);
//actual file name with the random number
$_file_name = $_random . basename($_FILES['file' . $i]['name']);
//do not upload the 'left blank' fields
if(basename($_FILES['file' . $i]['name']) != '')
{
if(move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path))
{
//uploaded successfuly
$_uploaded=1;
$bild = $bild . $i;
mysql_query("UPDATE news SET $bild = $_file_name WHERE date = $date");
}
else
{
//error uploading
$_error=1;
}
}
else
{
$_check=$_check+1;
}
}
//file(s) did upload
if($_uploaded == '1')
{
$_uploaded=0;
echo "The file(s) have been uploaded.<br>";
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "There was an error uploading some of the file(s), please try again! Maybe the file size. Maximum file size is " . $_max_file_size/1000 . "KB<br>";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "Select a file first than click 'Upload File'<br>";
}
}
?>
Danke im Vorraus,
stiff