Friday 24 November 2017

php - I am getting error for move_uploaded_file while trying to upload file on my live site

here is the
error



Warning: move_uploaded_file()
[function.move-uploaded-file]: open_basedir restriction in effect.
File(C:\Windows\Temp\php205.tmp) is not within the allowed path(s):
(E:\inetpub\vhosts\astradingcompany.org\httpdocs) in
E:\inetpub\vhosts\astradingcompany.org\httpdocs\mycar\postaddata.php on line
26




Warning:
move_uploaded_file(mycar/uploads/car001.jpg) [function.move-uploaded-file]: failed to
open stream: No such file or directory in
E:\inetpub\vhosts\astradingcompany.org\httpdocs\mycar\postaddata.php on line
26



Warning: move_uploaded_file()
[function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\php205.tmp' to
'mycar/uploads/car001.jpg' in
E:\inetpub\vhosts\astradingcompany.org\httpdocs\mycar\postaddata.php on line
26



here is the code
sippet



if
($_FILES['file']['error'] === UPLOAD_ERR_OK)
{

if((($_FILES['file']['type'] == 'image/gif')

||
($_FILES["file"]['type'] == 'image/jpg')
|| ($_FILES["file"]['type'] ==
'image/png')
|| ($_FILES["file"]['type'] == 'image/jpeg'))

//&& ($_FILES["file"]['size'] < 20000)
&&
(in_array($extensions, $allowedextensions)))
{
if
(file_exists("mycar/uploads/". $_FILES['file']['name']))
{
$msg =
$_FILES['file']['name']. " color='red'>File Already Exists";

header('Location:postad.php?msg='.$msg);

}

else
{
// $filename = "mycar/uploads/"
.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],
"mycar/uploads/" . $_FILES['file']['name']);
//
is_uploaded_file($_FILES['file']['tmp_name']), "uploads/" .
$_FILES['file']['name'];
//
is_uploaded_file($_FILES['file']['tmp_name'],"uploads/" .
$_FILES['file']['name']);
// copy($_FILES['file']['tmp_name'],
$uploaddatafile);
// copy($_FILES['file']['tmp_name'],
$filename);

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...