Phorum.ro
Your Avatar Welcome to Phorum.ro!
If you haven't registered yet, click here!
Attention Visitor:
You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Du-te înapoi   Phorum.ro > Web Design & Web Development > Programare > PHP > Discutii Generale

Discutii Generale Discutii generale despre PHP.

Răspunde
 
Thread Tools Moduri de afișare
Vechi 26.01.2009   #1
PirO
8-Bit Member
 
Data înregistrării: 13.01.2009
Mesaje: 3
Rep Power: 4
PirO is on a distinguished road
Question Upload si nu merge

class Upload {
var $up_file;
var $f;
var $p;
var $name;
var $size;
var $width;
var $height;
var $type;
var $max_size;
var $path;
var $directory;
var $errors;
var $move;

function Upload($input_name,$size,$width,$height,$dir) {
$this->f = $input_name;
$this->max_size = $size;
$this->directory = $dir;
$this->max_width = $width;
$this->max_height = $height;
}

function do_upload($audio=NULL) {
//global $_FILES;
$this->up_file = $_FILES[$this->f]['tmp_name'];
$this->name = $_FILES[$this->f]['name'];
$this->size = $_FILES[$this->f]['size']/10000;
$this->type = $_FILES[$this->f]['type'];
if (ereg(".gif$", $this->type) && ($audio == NULL)) $this->type="gif";
elseif((ereg(".png$", $this->type)||
ereg(".x-png$", $this->type)) && ($audio == NULL)) $this->type="png";
elseif((ereg(".jpg$", $this->type)||
ereg(".jpeg$", $this->type)||
ereg(".pjpeg$", $this->type)) && ($audio == NULL)) $this->type="jpg";
elseif(ereg(".mp3$", $this->type) && (($audio == '1') || ($audio == '3'))) $this->type="mp3";
elseif(ereg(".wav$", $this->type) && (($audio == '1') || ($audio == '3'))) $this->type="wav";
elseif(ereg(".mpeg$", $this->type) && (($audio == '1') || ($audio == '3'))) $this->type="mp3";
elseif(ereg(".midi$", $this->type) && (($audio == '1') || ($audio == '3'))) $this->type="mid";
elseif(ereg(".asf$", $this->type) && ($audio >= '2')) $this->type="asf";
elseif(ereg(".wmv$", $this->type) && ($audio >= '2')) $this->type="wmv";
elseif(ereg(".mpeg$", $this->type) && ($audio >= '2')) $this->type="mpg";
elseif(ereg(".mpg$", $this->type) && ($audio >= '2')) $this->type="mpg";
elseif(ereg(".msvideo$", $this->type) && ($audio >= '2')) $this->type="avi";
elseif(ereg(".octet-stream$", $this->type) && ($audio >= '2')) $this->type="3gp";
else $this->type=":".$this->type;
$this->path = $this->directory;
$this->width = $this->height = '';
if($audio != NULL) {
if(!empty($this->up_file)&&(C_HACK3)) {
$this->p = getimagesize($this->up_file);
$this->width = $this->p[0];
$this->height = $this->p[1];
}
}
$this->errors = '';

if($this->move_file($audio)) return true;
else return false;
}

function getName() {
return $this->name;
}

function getMaxSize() {
return $this->max_size;
}

function getSize() {
return $this->size;
}

function getType() {
return $this->type;
}

function move_file($audio=NULL) {
if($this->check_size() && $this->check_extension() && $this->check_uploaded() && $this->check_wh()) {
$newpath = ($audio == NULL) ? $this->path : $this->path.'.'.$this->type;
move_uploaded_file($this->up_file, $newpath);
chmod($newpath, 0644);
return true;
} else {
return false;
}
}

function check_size() {
global $w;
if(($this->up_file != "")&&($this->size <= $this->max_size)) {
return true;
} else {
if($this->errors == '') {
$tm=array($this->max_size,$this->size);
$this->errors = $this->errors.template($w[220],$tm);
}
return false;
}
}

function check_wh() { // Check width and height
global $w;
if(($this->up_file != "")&&($this->width <= $this->max_width)&&($this->height <= $this->max_height)) {
return true;
} else {
if($this->errors == '') {
$tm=array($this->max_width,$this->max_height);
$this->errors = $this->errors.template($w[221],$tm);
}
return false;
}
}

function check_uploaded() {
global $w;
if(is_uploaded_file($this->up_file)) {
return true;
} else {
if($this->errors == '') {
$this->errors = $this->errors.$w[1].'4';
}
return false;
}
}

function check_extension() {
global $w;
if (substr($this->type,0,1) == ":") {
if($this->errors == '') {
$this->errors = $this->errors.$w[222].$this->type;
}
return false;
} else {
return true;
}
}

function getErrors() {
return $this->errors;
}

}
?>

Ce ii gresit aici ? ca ii setat sa uploadeze maxim 10 Mb nu? si nu ma lasa doar 2 mb maxim :-? la audio.. iar la imagini cum as putea sa faca o redimensiune a pozelor? Ma puteti ajuta va rog...
PirO is offline   Reply With Quote
Sponsored Links
Răspunde


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Moduri de afișare

Reguli de postare
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Pornit
emoticoanele sunt Pornit
Codul [IMG] este Pornit
Codul HTML este Pornit



Ora este GMT +3. Ora este acum 02:47:31.


Rulează cu: vBulletin Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Forum SEO by Zoints

XXXXXXXXXXXXXXXXXXX
Inactive Reminders By Icora Web Design