RE: [PHP] Upload Question with mySQL

From: Date: Sat, 12 Apr 2003 07:59:54 +0000
Subject: RE: [PHP] Upload Question with mySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143600@lists.php.net to get a copy of this message
u an try using the pear upload class, it can handler multiple uploads and store in the database while in the loop for example notice the insert image and resize functions they are happening while uploading. function _upload_images(){ $this->_set_path(); $this->thumb_path = $this->dest_path.$this->thumb_path; //PEAR file upload with error handling $upload = new http_upload('en'); $bar = new progress_bar(); //get array of files $files = $upload->getFiles(); //loop for each file //check for max_file_size error foreach ($files as $key=>$file) { $array = get_object_vars($file); if ($file->isError()) { $error[name][] = $array[upload][name]; $error[error][] = $array[upload][error]; } } if ($error) { foreach($error[name] as $value) { $str .= $value."<br>"; } $_SESSION['uploaded_files'] = $str; $this->_trigger_error($error[error][0]); } $bar->open_progressbar('Uploading Please Wait'); foreach ($files as $file) { //allowed file extension $info = $file->setValidExtensions($this->imgtypes,$mode = 'accept',$this->img_mime_types); $name = $file->getProp('name'); if ($file->isValid()) { $name = $this->setName($name); $file->setName($name); //set destination dir and clean extra slashes $this->dest_name = $file->moveTo($this->dest_path); if (PEAR::isError($this->dest_name)) { switch ($this->dest_name->getCode()) { case 'NOT_ALLOWED_EXTENSION': $this->_trigger_error($this->dest_name->getCode(),$info[ext],$info[mime],fal se,$file->getProp('name')); break; case 'NOT_ALLOWED_MIMETYPE': $this->_trigger_error($this->dest_name->getCode(),$info[ext],$info[mime],fal se,$file->getProp('name')); break; case 'MISSING_DIR': $this->_trigger_error($this->dest_name->getCode(),$info[ext],$info[mime],fal se,$file->getProp('name')); break; } } else { $this->_resize($this->dest_path,$this->dest_path.$this->thumbs_dir,$this->de st_name,$this->thumb_width,$this->quality); $this->_insert_image(); } } $i++; $bar->progressbar_percentage($i,$files,'Uploading '.$this->dest_name); } $bar->close_progressbar('Processing Complete'); $this->_clear_error_session(); return $this->dest_name; } i can tell u what i'd do , save u making the previews , why not try mplayer , i'm sure it can output a 30 sec clip for u , it can also get a screen grab and output it as jpeg check it out. -----Original Message----- From: Inpho [mailto:inphorm@gmx.net] Sent: Saturday, April 12, 2003 4:20 PM To: php-general@lists.php.net Subject: [PHP] Upload Question with mySQL Hi All, I'm running a windows / apache server with php 4 installed. I'm fairly new to php. What I want to do is to have a user fill in a form with some details: title, shdesc, lngdesc, preview, fullmov,catid Now I can get all those details in to the mySQL database fine, what I want to do is have the user upload a short .avi file (under 10mb) with those details and to have them stored in the folder d:\movies on the server. There will also be a preview version of each .avi at about 30secs long that will need to be uploaded to the same directory. Once the movie is uploaded I need to have the directory and file name stored in the mysql database under preview and fullmov. Any help? Thanks - inpho - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#143600) next »