Welcome Guest, Not a member yet? Register   Sign In
Upload file error: HTTP wrapper does not support writeable connections
#1

[eluser]red apple[/eluser]
Hi,

I have a function in my controller to upload images. Everything seems to work okay, until where the file has to be moved from tmp path to the new location. I have an error message:


Message:

move_uploaded_file(HTTP:///public/img/6948face.bmp) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections
Filename: controllers/home.php
Line Number: 370
There was a problem moving your file.


Please, any advice are welcome. My function is below:

function upload_image()
{
$username = $_SESSION['username'];
$talentID = $_POST['talentID'];
$this->load->library('ftp');

$config['hostname'] = '***********';
$config['username'] = '***********';
$config['password'] = '***********';
$config['port'] = 21;
$config['passive'] = FALSE;
$config['debug'] = TRUE;

$this->ftp->connect($config);
$upload_dir = "HTTP://".$_SERVER['SERVER_NAME']."/public/img/";

$filename = basename( $_FILES['image']['name']);
$random_digit = rand(0000,9999);
$allowed_file_type = array ('image/jpeg',
'image/gif',
'image/png',
);
$max_size = '5000';
$max_width = '1280';
$max_height = '1024';
$new_file_name = $random_digit.$filename;

if (is_uploaded_file($_FILES['image']['tmp_name']))
{
ini_set('memory_limit', $size_bytes.'M');
$size = $_FILES['image']['size'];

//make sure if size is less than 4 min
if ($size > $size_bytes)
{
echo "File Too Large. File must be <b>$size_bytes</b> bytes.";
exit();
}

//check file type
if (($limit_file_type == "yes") && (!in_array($_FILES['image']['type'],$allowed_file_type)))
{
echo "Wrong File Type";
exit();
}
Here starts the issue!!!!
//move the file to to a new location
if (move_uploaded_file($_FILES['image']['tmp_name'],$upload_dir.$new_file_name))
{
$this->db->set('photo_profile1', $new_file_name);

//resize photo

$width = '500';
$max_height = '235';
$this->load->library();
chmod($upload_dir.$new_file_name, 0777);

$data['query'] = $this->Talentmodel->upload_photo($username, $talentID, $new_file_name) ;
$this->load->view('succes', $data);

}
else
{
echo "There was a problem moving your file";
exit();
}
}
}




Theme © iAndrew 2016 - Forum software by © MyBB