#1 2019-02-19 00:44:52

kristinaslife
Endora uživatel
Registrován: 1970-01-01
Příspěvky: 1

upload súboru

Dobrý deň.
Nefunguje mi upload obrázkov.

<?php
$target_dir = "profilovky/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
    // Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, jako.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 50000000) {
    echo "Príliš veľký obrázok!";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        $subor=basename( $_FILES["fileToUpload"]["name"]);
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
Db::query('
                        UPDATE uzivatelia
                        SET foto=?
                        WHERE meno=?
                ', $subor, $_SESSION['uzivatel_meno']);


    } else {
        echo "Sorry, there was an error uploading your file.";

    }
}
}

?>

Viete mi s tým pomôcť? Vyhadzuje mi tú poslednú chybu "Sorry, there was an error uploading your file."
Vďaka.

Offline

#2 2019-02-19 12:11:42

JF
Endora rádce
Místo: ....nice u Plzně
Registrován: 2010-06-22
Příspěvky: 11,888

Re: upload súboru

Dobrý den, prosím viz error log který je dostupný na ftp v složce .tmp

PHP Warning:  move_uploaded_file(web/profilovky/opica.PNG): failed to open stream: No such file or directory

Tj upravte cestu k adresáři aby byla napsána správně, doporučuje se absolutní cesta.


Ján Fačkovec - Endora.cz by Webglobe
Email, Web, Webadmin, Webmail, Nápověda, Ceník

Offline

Zápatí

Založeno na FluxBB | CZ a SK