media @ VU
[] readme course(s) preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthought(s) appendix reference(s) example(s) resource(s) _

talk show tell print

wiki-fileupload.php



  <?php
  
  //include 'wiki-config.php'
  
   scratch = 'd:/www/media/';
   webhome = 'http://localhost/media/';
  
  // In PHP versions earlier than 4.1.0, HTTP_POST_FILES should be used instead
  // of _FILES.
  
  //Select upload directory
  if(_POST["model_EQS"]!="0"){
  	uploaddir = scratch._POST["make_id_EQI"].'/'._POST["model_EQS"].'/';
  	//uploaddir = 'd:/www/hush/wiki/upload/'._POST["make_id_EQI"].'/'._POST["model_EQS"].'/';
  }
  else{
  	uploaddir = scratch._POST["make_id_EQI"].'/';
  	//uploaddir = 'd:/www/hush/wiki/upload/'._POST["make_id_EQI"].'/';
  }
  
  
  //check rename
  if(_POST["hernoem"]){
  	uploadfile = uploaddir . _POST["hernoem"];	
  	uploadfile_kaal = _POST["hernoem"];
  }
  else{
  	uploadfile = uploaddir . basename(_FILES['userfile']['name']);
  	uploadfile_kaal = basename(_FILES['userfile']['name']);
  }
  
  //Set final Webdir
  if(_POST["model_EQS"]!="0"){
  	//website = 'http://localhost/hush/wiki/upload/'.$_POST["make_id_EQI"].'/'._POST["model_EQS"].'/'.uploadfile_kaal;
  	website = webhome._POST["make_id_EQI"].'/'._POST["model_EQS"].'/'.uploadfile_kaal;
  }
  else{
  	//website = 'http://localhost/hush/wiki/upload/'.$_POST["make_id_EQI"].'/'.uploadfile_kaal;
  	website = webhome._POST["make_id_EQI"].'/'.uploadfile_kaal;
  }
  
  
  
  //check file size
  fsize = _FILES["userfile"]["size"];
  if(fsize == 0 || fsize > 12100000){
          error = "filesize";
  } 
  
  //check if file already exists
  if (file_exists(uploadfile)) {
     error = "exists";
  } 
  
  if(!error){
          if (move_uploaded_file(_FILES['userfile']['tmp_name'], uploadfile)) {
  
          } 
          else {
             error = "move";
          }
  }
  
  //echo 'Here is some more debugging info:';
  //print_r(_FILES);
  
  ?>
  
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <html>
  <head>
  <title>Upload file</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <link href="css/style.css" rel="stylesheet" type="text/css">
  
  <script language="JavaScript" type="text/JavaScript">
  </script>
  
  <body>
  
  <center>
  <table border=1 width=500>
          <tr>
                  <td colspan=4 align=center><b>upload</b>
                  / <a href=wiki-dirview.php?titel=documents>documents</a>
                  </td>
          </tr>
          <tr>
                  <td colspan=4 height=10></td>
          </tr>
          <tr>
                  <td width=10 height=10></td>
                  <td colspan=2>
                          <?php
  			if(!error){
  				echo	"file uploaded:

" . "website
" . "
" . "continue
" . "