php - how to set path for uploaded files using zend framework? -


i trying upload video , convert in php using zend framework , have bit of problem logic.

i have directory, locally, needs hold uploaded files:

c:/xampp/htdocs/zend/videos/ 

fist need convert video move in directory.

for conversion im using this:

exec("ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv", $out); 

here part of form:

$file = new zend_form_element_file('file');     $file->setlabel('file')         ->setrequired(true)         //->setdestination('/var/www/tmp') use in real life         ->setdestination('c:/xampp/htdocs/zend/tmp')         ->addvalidator('size',                 false,                 array('min' => '10kb', 'max' => '100mb')); 

when upload file goes directory fine.

do need convert file in tmp directory , move other main one, delete original one?

isn't there way hold original file in temp directory temporary until gets converted , automatically delete itself?

i trying use zend_file_transfer_adapter_http im bit confuse on difference in between setdestination , target rename filter , if there need use it.

i home bring light issue, maybe best practices.

thanks

i trying use zend_file_transfer_adapter_http im bit confuse on difference in between setdestination , target rename filter , if there need use it.

setdestination() deprecated, , rename filter should used instead. if have rename filter set, override destination. otherwise, there isn't of difference. main difference rename filter can rename file, setdestination keeps original file name on user's pc , moves destination. lead existing files being overwritten or smashing user's file if don't name them.

do need convert file in tmp directory , move other main one, delete original one?

personally, wouldn't try convert file uploaded. while conversion may quick in many cases, happens if relatively large video uploaded , takes additional 4 minutes encode video? don't want user hanging there waiting wondering happening while conversion takes place.

i upload files, copy them temporary location converted , moved original location. adds complexity of course.

if want convert videos on fly uploaded, may not bother using zend_file_transfer_adapter_http @ all. instead, use $_files superglobal access $_files['videofile']['tmp_name'] , have ffmpeg convert file , write output final destination, or temp destination , move when conversion completes. files uploaded php deleted automatically when request terminates unless call move_uploaded_file or manually write temporary file permanent location.

isn't there way hold original file in temp directory temporary until gets converted , automatically delete itself?

yes, if go without zend_file_transfer. uploaded file automatically in temporary directory until php request terminates. if conversion on fly, original temp file automatically deleted when php finishes.

hopefully clears things bit you.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -