Wenn ich versuche, eine Datei hochzuladen, erhalte ich einen HTTP 500 Fehler. Wenn mir jemand in die richtige Richtung zeigen könnte. Es gibt drei Dateien, Upload.php, upload_success.php und upload_form.php. Ich habe die Autoload-, Config-, Datenbank-Dateien richtig eingerichtet.Codeignender File Upload Interner Server Fehler
<?php
class Upload extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->database();
}
public function index() {
$this->load->view('upload_form', array('error' => ' '));
}
public function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = '*';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;
$this->load->library('upload', $config);
if (! $this->upload->do_upload('userfile')) {
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else {
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
}
?>
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<h3>Your file was successfully uploaded!</h3>
<ul>
<?phpforeach ($upload_data as $item => $value):?>
<li><?php echo $item;?>: <?php echo $value;?></li>
<?phpendforeach; ?>
</ul>
<p><?php echo anchor('upload', 'Upload Another File!'); ?></p>
</body>
</html>
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('upload/do_upload');?>
<form action = "" method = "">
<input type = "file" name = "userfile" size = "20" />
<br /><br />
<input type = "submit" value = "upload" />
</form>
</body>
</html>
verwenden Sie localhost Server oder einen Produktionsserver (wie einen Shared-Hosting-Server)? – Vickel
vielleicht ein Berechtigungsproblem? – Pipe
Könnte sein, Ihre htaccess Datei und Ordner Berechtigungen 0777 für Uploads Ordner stellen Sie auch sicher, dass Sie Ihre Config-Basis-URL nicht leer in config.php – user4419336