Hi,
I am trying to upload my images using my ftp folder by php code.Begining it was worked very fine.recently i shifted my domain from one server to another one server now if i am trying upload any images it storing path into database and its not uploading that image into specified folder it showing error like this,

Warning: move_uploaded_file(cms\ offer3.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Domains\ddd\wwwroot\cms\noticeboard_cms.php on line 36 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpE97F.tmp' to 'cms\ offer3.jpg' in C:\Domains\ddd\wwwroot\cms\noticeboard_cms.php on line 36
Please anyone can help me.

here is the code

<?PHP
     $image_name = $_FILES['image']['name'];

    $target_path1 = "cms/";
    $target_path1 = $target_path1.$image_name;
    if(is_uploaded_file($_FILES['image']['tmp_name']))
    {
        $userfile_type = $_FILES['image']['type'];
        if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif"))
        {
           echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
           exit;
        }
        if(move_uploaded_file ($_FILES['image']['tmp_name'],$target_path1))
        {
          //createThumbnails($image_name);
          //chmod("$add",0777);
        }
        else
        {
          echo "Failed to upload file Contact Site admin to fix the problem";
          exit;
        }
    }
	}
?>

Recommended Answers

All 3 Replies

the folder in which you are uploading the image have all permissions?

and if you are working online server also apply a check with captal extensions like file type='JPEG' or file type='GIF' as well because online server is always case sensitive

Hi,
Folder is having 777 permission.I gave file type='JPEG' or file type='GIF' also but now also the same problem is coming

Warning: move_uploaded_file(cms/images/imageupl/offer3.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Domains\inter.com\wwwroot\cms\noticeboard_cms.php on line 36 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php53E7.tmp' to 'cms/images/imageupl/offer3.jpg' in C:\Domains\inter.com\wwwroot\cms\noticeboard_cms.php on line 36

the folder in which you are uploading the image have all permissions?

and if you are working online server also apply a check with captal extensions like file type='JPEG' or file type='GIF' as well because online server is always case sensitive

I gave folder permission as 777 and i gave
file type='JPEG' or file type='GIF' but still i amg getting error.

Warning: move_uploaded_file(cms/images/imageupl/offer3.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\Domains\inte.com\wwwroot\cms\noticeboard_cms.php on line 36 PHP Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php53E7.tmp' to 'cms/images/imageupl/offer3.jpg' in C:\Domains\inter.com\wwwroot\cms\noticeboard_cms.php on line 36
Thanks

the folder in which you are uploading the image have all permissions?

and if you are working online server also apply a check with captal extensions like file type='JPEG' or file type='GIF' as well because online server is always case sensitive

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.