Die upload-Zielordner nicht angezeigt werden, schreibbar. (Codeigniter)

Habe ich zwei upload-Skripts, die sehr ähnliche Funktionen, nur mit verschiedenen Verzeichnissen.

function town_upload() {


        //Do not create a thumbnail
        $create_thumb = false;

        //Create the path for the upload
        $path = './public/uploads/towns/' . $this->uri->segment(3);

        $config['upload_path'] = $path;
        $config['allowed_types'] = 'jpg';
        $config['max_size'] = '2048';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $config['remove_spaces'] = TRUE;
        $config['overwrite'] = $this->image_upload_overwrite;

        if ($this->input->post('image_type') == 'main_image') {
            $config['file_name'] = 'main.jpg';
            $create_thumb = true;
        } 

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload()) {

            $this->session->set_flashdata('upload_error', array('error' => $this->upload->display_errors()));

        } else {

            //sucess so now we create the thumbnail
            $this->session->set_flashdata('upload_success', $this->upload->data());

Beispiel: Wenn ich eine Stadt mit der Nummer 6, ist das upload-Verzeichnis wäre public/uploads/Städte/6. Dies funktioniert perfekt in Ordnung, so wie das Verzeichnis wird erstellt, wenn die Stadt erstellt. Ich habe fast die exakt gleiche Funktion für hotels außer dem Pfad public/uploads/hotels/[ID]. Ich habe die Berechtigungen auf 777 nur zu entfernen, die aus der Gleichung für jetzt.

Kann ich nicht herausfinden, da Sie beide sehr ähnliche Funktionen. Hier ist das hotel-upload-code:

 function hotel_upload() {

        //Create the path for the upload
        $path = './public/uploads/hotels/' . $this->uri->segment(3);

        chmod($path, 0777);

        $config['upload_path'] = $path;
        $config['allowed_types'] = 'jpg';
        $config['max_size'] = '2048'; //kilobytes (2048 = 2mb)
        $config['max_width'] = '1024';
        $config['max_height'] = '768';
        $config['remove_spaces'] = TRUE;
        $config['overwrite'] = TRUE;

        if ($this->input->post('image_type') == 'main_image') {
            $config['file_name'] = 'main.jpg';
        }

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload()) {

            $this->session->set_flashdata('upload_error', array('error' => $this->upload->display_errors() . ' <br/>Path: ' . $path . '<br/>Image Type: ' . $this->input->post('image_type')));

        } else {

            //sucess so now we create the thumbnail
            $this->session->set_flashdata('upload_success', $this->upload->data());

Die hotel-Funktion gibt mir die Fehlermeldung "upload-Zielordner nicht angezeigt werden, schreibbar.".

Hier sind die Seiten, die HTML-Formulare:

STADT:

<?php echo form_open_multipart('admin/town_upload/' . $this->uri->segment(3));?>

            <input type="file" name="userfile" size="20" />

            <br /><br />

            <p>
                <input type="radio" name="image_type" checked="checked" class="radio" value="main_image" /> <label>Main Image</label>
                <input type="radio" name="image_type" class="radio" value="other_image" /> <label>Other Image</label>
            </p>

            <input type="submit" class="submit short" value="upload" />

        <?php echo form_close(); ?> 

HOTEL:

<?php echo form_open_multipart('admin/hotel_upload/' . $this->uri->segment(3));?>

            <input type="file" name="userfile" size="20" />

            <br /><br />

            <p>
                <input type="radio" name="image_type" checked="checked" class="radio" value="main_image" /> <label>Main Image (shown when visitors search the website)</label>
                <input type="radio" name="image_type" class="radio" value="other_image" /> <label>Standard Image</label>
            </p>

            <input type="submit" class="submit short" value="upload" />

        <?php echo form_close(); ?> 

Vielen Dank im Voraus! Schon Stunden jetzt.. 🙁

Alles, Beispiel-code, der erforderlich ist, um die Frage beantworten? Ich Zweifel so. Bieten ein kurzen Beispiel, das das problem reproduziert.
Hat das Ziel-Verzeichnis auch wirklich existiert? Wo schaffen Sie das? Sind beide Skripte im selben Verzeichnis?
Das ist der gesamte code, der erforderlich ist, wie das hotel-upload-Skript als do_upload Methode immer false zurückgegeben. Mit der HTML-Formular-ich behaupte ein einfaches Bild, das alle Anforderungen erfüllt.
beide Scripte sind in der gleichen controller, und das Ziel-Verzeichnis existiert, wie ich habe viele Male mit einem FTP-client. Wenn es existiert nicht eine andere Fehlermeldung zeigt auf jeden Fall.
können Sie versuchen is_writable() auf das Verzeichnis?

InformationsquelleAutor SamV | 2011-04-24

Schreibe einen Kommentar