Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:07:22+00:00 2026-06-10T15:07:22+00:00

I want to do a simple copy using a ajax call. this is my

  • 0

I want to do a simple copy using a ajax call. this is my code but it does not work . i kepp getting : a copy(../../images/merchant/particulars/208/) failed to open stream: Is a directory in some/filepath on scriptname.php line x , kind of error.

corrected code: 

$dir_to_make = '../../images/merchant/particulars/'.$copytothisstore;
$dir = '../../images/merchant/particulars/'.$copytothisstore.'  /'.$copyvalue;
$image_to_copy = '../../images/merchant/particulars/'.$copyfromthisstore.'/'.$copyvalue;






    if(is_file($image_to_copy)){

        //chk if there is a folder created for this store
        if(!is_dir($dir_to_make)){
              mkdir($dir_to_make, 0755);  
              chmod($dir_to_make, 0755);

              //copy the image 
              if (!copy($image_to_copy,$dir)) {
                  echo "failed to copy $image_to_copy\n";
              } else {
                  echo"all is well!!";
              }

           } else {
               chmod($dir_to_make, 0755);
               if (!copy($image_to_copy,$dir)) {
                  echo "failed to copy $image_to_copy\n";
              } else {
                  echo"all is well!!";
              }

           }


           echo"$image_to_copy does exist!";
        } else{
            echo"$image_to_copy does not exist!";
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:07:24+00:00Added an answer on June 10, 2026 at 3:07 pm

    Please read your error.

    copy(../../images/merchant/particulars/208/) failed to open stream: Is a directory in some/filepath
    

    It says that your source file is not a file, but directory.

    Simple debugging could always solve your problems:

    $image_to_copy ='../../images/merchant/particulars/'.$copyfromthisstore.'/'.$copyvalue;
    echo $image_to_copy; // yes, that could give you the answer
    

    It will show you, that $copyvalue in you example is empty.


    If you wonder why this is returning TRUE…

    if(file_exists($image_to_copy)){
    

    ..it’s because directory ../../images/merchant/particulars/208/ does exists.

    As manual says:

    • file_exists() – Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.

    You should change it to:

    if(is_file($image_to_copy)){
    
    • is_file() – Returns TRUE if the filename exists and is a regular file, FALSE otherwise.

    Another thing is destination shuld be file as well:

    copy($image_to_copy, $dir.'file.jpg');
    

    Manual:

    • http://php.net/manual/en/function.copy.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get this really simple example of using AJAX with JQuery
i am using wix 3.0.i have a folder name images.so i want to copy
I want to write Html format, but I can not even get a simple
I'm using ant to build my web-app. I'm sure this is simple but I
I've got this to work using a very basic example(outlined below) and I want
There is probably a very simple answer to this, but I want to be
I want to write simple script to copy/backup directory then remove on server startup.
For some simple Windows batch script, I want to temporarily create a copy of
I want a simple TextView to behave the way simple_list_item_1 in a ListView does.
This one very simple thing I can't find the right technique. What I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.