无法使用curl上传图像

I want to upload images from my Server to another Server with php curl. I tested my script on localhost it works but on server it not working.

Here are my steps:

First step

I upload an image to my server. Path of the image is "imgs/myimage.jpg"

Second step

I excute this code for upload image from my server to another server.

$file_name_with_full_path = realpath("imgs/myimage.jpg");
$postdata = array('myfile'=>'@'.$file_name_with_full_path); 

$headers = array("Content-Type:multipart/form-data");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL, "http://www.secondserver.com/image.php");    
$data = curl_exec($ch);        
curl_close($ch);

This code in image.php from second server.

print_r($_FILES["myfile"]);

I tested this code on localhost it works. But on Server it not working and display error.

Notice: Undefined index: myfile in ....

I try to get full path of the image on the server with command

echo realpath("imgs/myimage.jpg");

It shows this:

@/home/admin/domains/mydomain.com/public_html/member/imgs/myimage.jpg

I'm not sure what it is about Permission? But I have also set up file permissions are 777.

What should I do to fix this problem?

I'm trying to find a solution for the entire day, but was not successful.

Update

I apply the code to test on another server. It worked. I try to get full path of the image on the server with command

echo realpath("imgs/myimage.jpg");

It shows this:

@/var/www/vhosts/myuser/mydomain.com/imgs/myimage.jpg

I think probably about Config Server. Should I set up?

Not sure if you updated code for posting here but $postdata is never set before. In your 2nd line, you have $postimg = array('myfile'=>'@'.$file_name_with_full_path); and later you do curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata); Please use the correct variable ($postimg) and you should be good to go. Wondering how it worked on local :)