Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Jak stworzyć upload plików poprzez stronę?
#3
DoGeR napisał(a):Możesz zainstalować gotowy skrypt uploadu. Link: http://skrypty.webpc.pl/index37.html

Wszystko ok, tylko nie umiem tego skonfigurować. wyskakuje mi cały czas błąd "Somthing is wrong with uploading a file". proszę o pomoc, ponizej kod którego użyłem:
Kod:
<?php

$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this =  "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

$upload_dir = "upload_files/";
$upload_url = $url_dir."/upload_files/";
$message ="";

//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("upload_files")) {
    die ("upload_files directory doesn't exist");
}

if ($_FILES['userfile']) {
    $message = do_upload($upload_dir, $upload_url);
}
else {
    $message = "Invalid File Specified.";
}

print $message;

function do_upload($upload_dir, $upload_url) {

    $temp_name = $_FILES['userfile']['tmp_name'];
    $file_name = $_FILES['userfile']['name'];
    $file_type = $_FILES['userfile']['type'];
    $file_size = $_FILES['userfile']['size'];
    $result    = $_FILES['userfile']['error'];
    $file_url  = $upload_url.$file_name;
    $file_path = $upload_dir.$file_name;

    //File Name Check
    if ( $file_name =="") {
        $message = "Invalid File Name Specified";
        return $message;
    }
    //File Size Check
    else if ( $file_size > 500000) {
        $message = "The file size is over 500K.";
        return $message;
    }
    //File Type Check
    else if ( $file_type == "text/plain" ) {
        $message = "Sorry, You cannot upload any script file" ;
        return $message;
    }

    $result  =  move_uploaded_file($temp_name, $file_path);
    $message = ($result)?"File url <a href=$file_url>$file_url</a>" :
              "Somthing is wrong with uploading a file.";

    return $message;
}
?>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
  Upload Image<input type="file" id="userfile" name="userfile">
  <input type="submit" name="upload" value="Upload">
</form>
Odpowiedz


Wiadomości w tym wątku
RE: serwer ftp - przez DoGeR - 18-07-2008, 22:05
RE: serwer ftp - przez jasikj - 21-07-2008, 16:55
RE: serwer ftp - przez DoGeR - 21-07-2008, 18:45
RE: serwer ftp - przez jasikj - 21-07-2008, 20:49

Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Jak założyć stronę www samemu dariusz.zbin 19 15,899 31-10-2022, 02:53
Ostatni post: wozniak
  zapłata za stronę Nicorrtiss 22 20,093 17-06-2021, 04:09
Ostatni post: wozniak
  Jak dopasować własną strone do Prestashop Witek7777 0 2,631 06-06-2015, 22:10
Ostatni post: Witek7777
  [CSS][HTML] Jak wycentrować strone Witek7777 3 4,636 27-05-2015, 14:43
Ostatni post: Kartofelek
  Jak stworzyć własną prezentację (magazyn) Damian M 5 5,438 25-11-2014, 20:07
Ostatni post: ironmaster

Skocz do:


Użytkownicy przeglądający ten wątek: 1 gości
Sponsorzy i przyjaciele
SeoHost.pl