How to get temporary path for uploaded file?

auroqn - October 21, 2007 - 15:07
Project:Upload previews
Version:5.x-1.2
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:by design
Description

Hi,
I need to get temporary path for my uploaded file. I'm trying to make simple .mov preview for upload preview module, but i'm not able to get the correct temporary path for uploaded file so i can embed it. here is simple code:

<?php
function upload_preview_upload_preview($file) {

 
// Only check for images
 
if (strpos($file->filemime, 'image/') === 0) {

      .......

  }
 
// my code starts here
 
if(strpos($file->filemime, 'video/quicktime') === 0) {

  
//this is critical, i believe this is not correct, i only need to get this $path...
   
$path =$_FILES["files"]["tmp_name"][$file->filename];

       
    if (
$path) {
      
      return array(
       
'#type' => 'upload_preview_mov',
       
'#value' => file_create_url($path),
      );
  }


}
}
//movie embed

function theme_upload_preview_mov($element) {
   
$mov ='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="150" width="150"> ';
   
$mov .='<param name="src" value="'.$element['#value'].'">';
   
$mov .='<param name="autoplay" value="false">';
   
$mov .='<param name="type" value="video/quicktime" height="150" width="150">';
   
$mov .='<embed src="'.$element['#value'].'" height="150" width="150" autoplay="false" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/">';
   
$mov .='</object>';
return
$mov;
}
?>

#1

cheridxb - September 18, 2008 - 14:53

try this

$fileTempPath = file_check_upload('upload')-> filepath;
echo '<br>'.$fileTempPath;

#2

rmiddle - October 9, 2008 - 04:20
Status:active» needs review

OK need to review this patch for inclusion into the dev version.

Thanks
Robert

#3

rmiddle - January 29, 2009 - 22:11
Status:needs review» won't fix

this isn't really a patch as more someone asking how to do something that was answerned long ago. I am going to make this wont fix.

#4

rmiddle - January 29, 2009 - 22:12
Status:won't fix» by design

Actually I think by design makes more since.

 
 

Drupal is a registered trademark of Dries Buytaert.