Click here to Skip to main content
14,927,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
excuse me guys, i wanna ask..

example :
PHP
<?php
   $no_pengajuan_full_day = $_POST['no_pengajuan_full_day'];
    $image = base64_decode($_POST['foto']);
    
    $nama = $no_pengajuan_full_day;
 
    $targer_dir = "C:/xampp/htdocs/img/".$nama.".jpeg";
    if (file_put_contents($targer_dir, $image)) {
        echo json_encode(array('response'=>'Success'));
    }else{
        echo json_encode(array("response" => "Image not uploaded"));
    }
   
?>

this code is worked and the file it's already send to target directory

but, is this a possible if i send file image to another computer server ? just like this
PHP
<?php
   $no_pengajuan_full_day = $_POST['no_pengajuan_full_day'];
    $image = base64_decode($_POST['foto']);
    
    $nama = $no_pengajuan_full_day;
 
    $targer_dir = "192.168.232.199/xampp/htdoc/training/uploads/image/images/".$nama.".jpeg";
    if (file_put_contents($targer_dir, $image)) {
        echo json_encode(array('response'=>'Success'));
    }else{
        echo json_encode(array("response" => "Image not uploaded"));
    }
   
?>


I appreciate that if someone give me an solution

What I have tried:

the error says :
Warning: file_put_contents(192.168.232.199/xampp/htdoc/training/uploads/image/images.jpeg): failed to open stream: No such file or directory in C:\xampp\htdocs\db_eis\upload.php on line 8
Posted
Updated 3-Nov-20 23:34pm
v4

1 solution

Try prefixing your UNC path with two forward slashes:
PHP
$targer_dir = "//192.168.232.199/xampp/htdoc/training/uploads/image/images/".$nama.".jpeg";
NB: You will need to validate the $nama variable to ensure that it doesn't contain any invalid file-name characters. Otherwise, an attacher could overwrite files in an unexpected directory by including ".." in the no_pengajuan_full_day field.
   
Comments
Komang Putra 4-Nov-20 5:54am
   
But sir... the error says

Warning: file_put_contents(//192.168.232.199/xampp/htdoc/training/uploads/image/images/.jpeg): failed to open stream: Permission denied in C:\xampp\htdocs\db_eis\upload.php on line 9
Richard Deeming 4-Nov-20 5:56am
   
That means your application is running as a user who doesn't have permission to write to that path. Check the permissions on the share and the NTFS permissions on the folder. You may need to change the user your application runs as to one with network permissions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900