[ Príspevkov: 5 ] 
AutorSpráva
Offline

Užívateľ
Užívateľ
switch

Registrovaný: 09.03.08
Prihlásený: 22.12.10
Príspevky: 356
Témy: 85 | 85
Bydlisko: Topoľčany
NapísalOffline : 22.05.2009 14:34 | switch

Chalani potrebujem trosku pomoct: tento kod potrebujem dosadit do druhého. a ze sa php len ucim mi to stale vypisuje nejaku chybu. diky
Kód:
switch ($_POST['storage_folder']) {

case "1": $storage_folder = "./smokovec"; break;
case "2": $storage_folder = "./strbskepleso"; break;
case "3": $storage_folder = "./lomnica"; break;
default : die("Nesprávne vybratá zložka"); break;
}


Kód:
<?php
class Upload{


var $storage_folder = './files';


var $site_url       = 'http://xxx/upload/.$storage_folder.';   
var $sidens_navn = 'Sidens_navn';
var $filesize_limit = 104857600;

var $allowed_extensions = array('jpg','jpeg','pjpeg');
var $allowed_file_types = array('image/jpg','image/jpeg','image/pjpeg');         
 
 
var $filename;
var $file_content;
var $filesize_actual;

//pokračovanie kódu...

?>


_________________
FCSpartak Trnava
Offline

Užívateľ
Užívateľ
switch

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233 | 233
Bydlisko: Nové Zámky
NapísalOffline : 22.05.2009 15:33 | switch

ako to ma potom vyzerat?
http://xxx/upload/files/smokovec ?

ak takto, tak potom:
Kód:
<?php

class Upload{


var $storage_folder = 'files';     
var $sidens_navn = 'Sidens_navn';
var $filesize_limit = 104857600;

var $allowed_extensions = array('jpg','jpeg','pjpeg');
var $allowed_file_types = array('image/jpg','image/jpeg','image/pjpeg');         
 
 
var $filename;
var $file_content;
var $filesize_actual;

function site_url ($storage_folder)
{   
   switch ($storage_folder) {
   
   case "1":
      $storage_folder .= "/smokovec";
   break;
   case "2":
      $storage_folder .= "/strbskepleso";
   break;
   case "3":
      $storage_folder .= "/lomnica";
   break;
   default :
      die("Nesprávne vybratá zložka");
   break;
   }
   
   return 'http://xxx/upload/'.$storage_folder;
}
//pokračovanie kódu...
}

?>


pouzitie:
Kód:
$u = new Upload;
$u->site_url($_POST['storage_folder']);
// a tak dalej


_________________
"It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď
Offline

Užívateľ
Užívateľ
switch

Registrovaný: 09.03.08
Prihlásený: 22.12.10
Príspevky: 356
Témy: 85 | 85
Bydlisko: Topoľčany
Napísal autor témyOffline : 22.05.2009 17:26 | switch

nie ten switch som chcel pouzit namiesto toho ./files. vies aby si uzivatel mohol prepnut do akej zlozky chce subor nahrat.


_________________
FCSpartak Trnava
Offline

Užívateľ
Užívateľ
switch

Registrovaný: 09.09.07
Prihlásený: 07.11.16
Príspevky: 3114
Témy: 233 | 233
Bydlisko: Nové Zámky
NapísalOffline : 23.05.2009 0:01 | switch

tak sem hod cely kod...
ak to robis ako triedu, tak tam ten switch nemozes len tak hodit.. musi byt vo funkcii.. tak bud to urobit ako _constructor, alebo to dat do funkcie, ktoru budes volat potom..


_________________
"It took a lot of work, but this latest Linux patch enables support for machines with 4096 CPUs, up from the old limit of 1024." "Do you have support for smooth full-screen flash video yet?" "No, but who uses that?"
- ak dlho neodpisujem do témy, zabudol som na ňu, takže ma upozornite SS, ak chcete moju odpoveď
Offline

Užívateľ
Užívateľ
switch

Registrovaný: 09.03.08
Prihlásený: 22.12.10
Príspevky: 356
Témy: 85 | 85
Bydlisko: Topoľčany
Napísal autor témyOffline : 23.05.2009 15:36 | switch

ok tu je kod:
Kód:
<?php
class Upload{

var $storage_folder = "./files";

var $site_url       = 'http://xxx/upload/files';   
var $sidens_navn = 'Sidens_navn';
var $filesize_limit = 104857600;

var $allowed_extensions = array('jpg','jpeg','pjpeg');
var $allowed_file_types = array('image/jpg','image/jpeg','image/pjpeg');         
 
 
var $filename;
var $file_content;
var $filesize_actual;
var $filetype_actual;
var $password;
var $filelink;
var $message;
var $show_error;

function Upload(){
$this->message = '';
$this->filelink = '';
$this->load_error ='';
$this->show_error = false;

if (!$_FILES){
$this->showview();
}else{
   
$this->filename = $_FILES['myfile']['name'];
$this->file_content = $_FILES['myfile']['tmp_name'];
$this->filesize_actual = $_FILES['myfile']['size'];
$this->filetype_actual = strtolower($_FILES['myfile']['type']);

if ($this->filesize_actual <= 0){
$this->show_error = true;
$this->message = 'Vennligst velg en fil ĺ laste opp';
$this->showview();   
}

if ($this->filesize_actual > $this->filesize_limit){
$this->show_error = true;
$this->message = '<img src="icon_feilmelding.png">Filen for stor!';
$this->showview();   

}

if (!in_array($this->filetype_actual, $this->allowed_file_types)){
$this->show_error = true;
$this->message = '<img src="icon_feilmelding.png">Filtypen er ikke lovlig';
$this->showview();   
}

$file_extension = end(explode('.',$this->filename));
if (!in_array($file_extension, $this->allowed_extensions) || $file_extension ==''){
$this->show_error = true;
$this->message = '<img src="icon_feilmelding.png">Filtypen er ikke lovlig';
$this->showview();   
}


if (!is_writeable($this->storage_folder)){
$this->show_error = true;
$this->message = '<img src="icon_feilmelding.png"><b>Mappen /files mĺ CHMODEs, gjřr dette řyeblikkelig!</b>';
$this->showview();   
}

$filename_random_code = $this->randomcode();
$filename_random = $this->storage_folder.'/'.$filename_random_code.'.'.$file_extension;
if (!move_uploaded_file($_FILES['myfile']['tmp_name'], $filename_random)) {
$this->show_error = true;
$this->message = 'Prřv igjen!';
$this->showview();
}else{
$this->filelink = $this->site_url.'/'.$filename_random_code.'.'.$file_extension;
$this->show_error = true;
$this->message = '<b>Direkte url</b><br><br>'.$this->filelink.'<br><br><b>Webside</b><br><p>&lt;img src="'.$this->filelink.'"/&gt;</p><b>Forum</b><br><br>[img]'.$this->filelink.'[/img]<br><br><b>Thumbnail</b><br><br><p><a href="'.$this->filelink.'" target="_blank" ><img src="'.$this->filelink.'" target="_blank" alt="Thumbnail" width="100" height="100" border="0" /></a><br><br><textarea><a href="'.$this->filelink.'" target="_blank" ><img src="'.$this->filelink.'"alt="Thumbnail" width="100" height="100" border="0" /></a></textarea>';
$this->showview();   
}


}
}


function showview(){


if ($this->show_error==true){


$load_error = '<font face="Verdana" size="1" color="#006699">'.$this->message.'</font>';
}

echo '<form action="index.php" method="post" enctype="multipart/form-data">
<input type="radio" name="storage_folder" value="strbskepleso" />&nbsp;<font color="#006699">Štrbské Pleso</font>
<input type="radio" name="storage_folder" value="lomnica" />&nbsp;<font color="#006699">Tatranská Lomnica</font>
<input type="radio" name="storage_folder" value="smokovec" />&nbsp<font color="#006699">Starý Smokovec</font>
 

<input name="myfile" type="file" size="25"/>
<input type="submit" width="114" height="21" value="upload" name="B1">';

      
die();

}
   
function randomcode() {
    $chars = "023456789";
    srand((double)microtime() * 1000000);
    $i = 0;
    $pass = '';

    while ($i <= 3) {
        $num = rand() % 33;
        $tmp = substr($chars,$num,1);
        $pass = $pass.$tmp;
        $i++;
    }

    return $pass;
}
}
?>


_________________
FCSpartak Trnava
 [ Príspevkov: 5 ] 


switch



Podobné témy

 Témy  Odpovede  Zobrazenia  Posledný príspevok 
V tomto fóre nie sú ďalšie neprečítané témy.

Nepouzivany 28 portovy poe switch switch tp link tl-sg1428pe

v Kôš

0

18

19.06.2022 20:59

andytwo

V tomto fóre nie sú ďalšie neprečítané témy.

Router-Switch-Switch

v Siete

8

1720

06.12.2007 9:11

stanley666

V tomto fóre nie sú ďalšie neprečítané témy.

Asus Transformer vs Acer Aspire Switch vs Aspire Switch 10E

v Mobilné zariadenia

9

1405

02.09.2015 17:42

R3Z0R

V tomto fóre nie sú ďalšie neprečítané témy.

Switch

v Ostatné

1

294

04.01.2018 12:53

void

V tomto fóre nie sú ďalšie neprečítané témy.

SWITCH

v Rozširujúce karty

4

1577

15.11.2006 22:32

maugggly

V tomto fóre nie sú ďalšie neprečítané témy.

switch

v Ostatné

7

540

17.01.2011 14:38

patro16

V tomto fóre nie sú ďalšie neprečítané témy.

Switch

v Ostatné

6

802

26.03.2008 14:18

SilverSurfer

V tomto fóre nie sú ďalšie neprečítané témy.

switch

v PHP, ASP

6

863

15.12.2007 13:54

TECHNODROME

V tomto fóre nie sú ďalšie neprečítané témy.

switch

v Siete

4

476

22.05.2012 11:51

Ares258

V tomto fóre nie sú ďalšie neprečítané témy.

SWITCH

v Ostatné

5

670

24.10.2008 13:33

Jaro

V tomto fóre nie sú ďalšie neprečítané témy.

...Switch...

v Ostatné

0

669

06.10.2008 21:52

Eris14

V tomto fóre nie sú ďalšie neprečítané témy.

Switch

v Ostatné

5

875

05.05.2008 16:34

SilverSurfer

V tomto fóre nie sú ďalšie neprečítané témy.

P: Switch

v Predám

24

1833

26.02.2012 15:09

dixi

V tomto fóre nie sú ďalšie neprečítané témy.

vga switch

v Monitory, televízory a projektory

3

975

27.09.2010 10:44

shiro

V tomto fóre nie sú ďalšie neprečítané témy.

HDMI switch

v Ostatné

1

531

01.10.2022 8:44

tatko Tom

V tomto fóre nie sú ďalšie neprečítané témy.

Java - Switch

v Assembler, C, C++, Pascal, Java

2

450

10.12.2015 22:23

ONIM



© 2005 - 2025 PCforum, edited by JanoF