<?php //katalog wysyłania. //change to fit your need eg. files, upload .... etc. $upload_dir = "uploads/klub_gal/"; //liczba formularzy do wysyłania $num_files = 2; //maxymalny rozmiar plików w bajtach. $size_bytes =51200; //51200 bytes = 50KB. //Extensions you want files uploaded limited to. $limitedext = array(".gif",".jpg",".jpeg",".png",".txt",".nfo",".doc",".rtf",".htm",".dmg",".zip",".rar",".gz",".exe"); //check if the directory exists or not. } //check if the directory is writable. } //if the form has been submitted, then do the upload process //infact, if you clicked on (Upload Now!) button. //do a loop for uploading files based on ($num_files) number of files. for ($i = 1; $i <= $num_files; $i++) { //define variables to hold the values. $new_file = $_FILES['file'.$i]; $file_name = $new_file['name']; //to remove spaces from file name we have to replace it with "_". $file_tmp = $new_file['tmp_name']; $file_size = $new_file['size']; #-----------------------------------------------------------# # this code will check if the files was selected or not. # #-----------------------------------------------------------# //print error message and file number. }else{ #-----------------------------------------------------------# # this code will check file extension # #-----------------------------------------------------------# }else{ #-----------------------------------------------------------# # this code will check file size is correct # #-----------------------------------------------------------# if ($file_size > $size_bytes){ echo "File $i: ($file_name) Faild to upload. File must be <b>". $size_bytes / 1024 ."</b> KB. <br>"; }else{ #-----------------------------------------------------------# # this code check if file is Already EXISTS. # #-----------------------------------------------------------# }else{ #-----------------------------------------------------------# # this function will upload the files. :) ;) cool # #-----------------------------------------------------------# }else{ }#end of (move_uploaded_file). }#end of (file_exists). }#end of (file_size). }#end of (limitedext). }#end of (!is_uploaded_file). }#end of (for loop). # print back button. //////////////////////////////////////////////////////////////////////////////// //else if the form didn't submitted then show it. }else{ echo " <h3>Select files to upload!.</h3> Max file size = ". $size_bytes / 1024 ." KB"; // show the file input field based on($num_files). for ($i = 1; $i <= $num_files; $i++) { } <input type="submit" name="upload_form" value="Wyślij Teraz"> </form>"; } ?>
i moje pytanie, niestety niewiem jak go przerobić na FUNKCJE... obejmowałem to klauzulą function{} ale niestety nie wysyła pliku, a ten sam kod wrzuciłem do CZYSTEGO pliki i działa... chciałbym to przystosować do CMS-a, jPortala
ale nie umiem
