Jump to content
php.lv forumi

Kas man butu jazina


Zoom
 Share

Recommended Posts

uploadeeshanai vienaa suudiigaa vietaa es izmantoju shaadu (nevisai smuku funkciju):

 

function UploadFile($inputfield_name,$upload_dir,$max_size){
$upload_file = $upload_dir.$_FILES[$inputfield_name]['name'];
if (($_FILES[$inputfield_name]['size'] <= $max_size) && ($_FILES[$inputfield_name]['size'] != 0))
 @move_uploaded_file($_FILES[$inputfield_name]['tmp_name'], $upload_file);
}

un HTML:

 <form enctype="multipart/form-data" method="POST">
 Pievienot failu (max: 2MB): <input name="userfile" type="file" size="16">
 <input type="submit" name="upload_file" value="Pievienot">
 </form>

 

un peec "Pievienot" nospieshanas:

 

 if ($_POST['upload_file']){
	 if ($_FILES['userfile']['size'] > 2097152){
   echo 'Fails par lielu! Maksimums: 2 MB';
	 }
	 else{
   UploadFile('userfile',$dir,'2097152'); // 2MB
   header('Location: index.php?dir='.$dir);
	 }
 }

 

 

Shitaas nav smukas lietas, bet nu man slinkums uzlabot, kameer klients (bratella) nesuudzaas, tikmeer labi! :)

 

Protams, tamster arii paklausi!

Edited by Toms
Link to comment
Share on other sites

 Share

×
×
  • Create New...