open_basedir restrictions and image upload

paia

No avatar

2006-09-02 01:16

is there any way, how to upload image, when open_basedir rectrictions are in use? I've solved it within my scripts this way:

$uploaddir = "/home/www/myweb/foto/";
$picdir = "./foto/";
$uploadfile = $uploaddir . $obr_index . ".jpg";
@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile); //@ - NEEDED TO OVERRIDE ERROR MESSAGE
$src_img = imagecreatefromjpeg($uploadfile);
$origw=imagesx($src_img);
$origh=imagesy($src_img);
$tnfile = $uploaddir . "tn_" . $obr_index . ".jpg";
$dst_img = ImageCreateTrueColor($new_w,$new_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,$origw,$origh);
imagejpeg($dst_img, $tnfile, 80);
chmod($tnfile, 0777);
chmod($uploadfile, 0777);

but I'm unable to find out, where is QC failing to save image...

paia

No avatar

2006-09-02 12:19

I'm so good... It's working now! Modifications I had to make...

FileJobs.php


    
if( move_uploaded_file$sUpFileSrc$sOutDir.$sFileOutName ) ){
      
chmod$sOutDir.$sFileOutName0777 );
      return 
$sFileOutName;
    }
    else
      return 
null



changed to:


    
@move_uploaded_file$sUpFileSrc$sOutDir.$sFileOutName );
    
chmod$sOutDir.$sFileOutName0777 );
    return 
$sFileOutName;



FotoJobs.php


      
if( is_uploaded_file$mImgSrc['tmp_name'] ) && is_file$mImgSrc['tmp_name'] ) && filesize$mImgSrc['tmp_name'] ) > && $this->checkCorrectFile$mImgSrc['name'], 'jpg|jpeg|gif|png' ) == ){



changed to:


      
if( is_uploaded_file$mImgSrc['tmp_name'] ) && $this->checkCorrectFile$mImgSrc['name'], 'jpg|jpeg|gif|png' ) == ){



I know, that these conditions are useful, but they are just incompatible with open_basedir restriction. These must be done AFTER move_uploaded_file...

bobby

No avatar

2006-11-17 21:05

I ran into this problem when I was using Open Solution on a class project.

This method works! Thanks!!!

Back to top
about us | contact