Form:Datei-Information von der Form nicht php geben
<form enctype="multipart/form-data" action="FileUpload.php" method="post">
<label for="file" class="myLabel">Select File</label>
<input type="file" id="file" name="fileUpload">
<input type="submit" class="submit" value="Upload File">
</form>
php:
if(isset($_FILES['fileUpload'])){
$uploadName = $_FILES['fileUpload']['name'];
$uploadTmp = $_FILES['fileUpload']['tmp_name'];
$fileSize = $_FILES['fileUpload']['size'];
$fileType = pathinfo($uploadName, PATHINFO_EXTENSION);
$uploadName = trim($uploadName, "." . $fileType);
$uploadName = preg_replace("#[^a-z0-9.]#i","",$uploadName);//removes all spaces in their name
$uploadName = mt_rand(100000,999999) . "____" . $uploadName;//generates random number in front of name so multiple files of the smae name can be uploaded
if(($fileSize > 100024352638512)){//check file is less than 10gb
die("Error - File to big");
}
if(!$uploadTmp){//checks to see if file is selected
die("No File Selected, Please Upload Again");
}else{
move_uploaded_file($uploadTmp,"uploads/$uploadName");//puts file into uploads directory
}
$sql = $con->query("INSERT INTO uploads (ID, Time ,Name, Type, Owner) VALUE
(NULL,CURRENT_TIMESTAMP(),'{$uploadName}','{$fileType}','{$_SESSION['UserID']}')")or die(mysqli_error($con));//inserts file into database
header("Location:Profile.php");//sends you to profile page
}
Der Code bis zum Ende ausgeführt wird, aber die Datei nicht in die Datenbank hochgeladen, ich die php hatte Ich habe vorher gearbeitet, aber ich habe geändert, wie die Eingabetaste funktioniert hat und jetzt funktioniert es nicht. Ich werde für jede Hilfe dankbar sein, da ich noch ein ziemlich neuer Entwickler bin.
Erwarten Sie, dass die tatsächliche Datei in die DB oder nur den Dateinamen geht? – developerwjk