i received error message Warning: ftp_put() [function.ftp-put]: /spencer: Access is denied. in C:\wamp\www\test3\index.php on line 18 Cannot upload

PHP
i received error message Warning: ftp_put() [function.ftp-put]: /spencer: Access is denied. in C:\wamp\www\test3\index.php on line 18 Cannot upload
i had try to connect with ftp client software and i can upload the file

below is my code
<?php
// FTP access parameters
$host = "1.2.3.4";
$usr = "admin";
$pwd = "admin";
 
// file to move:
$local_file = 'c:/TEST/test.txt';
$ftp_path = '\\spencer';
 
// connect to FTP server (port 21)
$conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
 
// send access parameters
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
 
// perform file upload
$upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);
 
// check upload status:
print (!$upload) ? 'Cannot upload' : 'Upload complete';
print "\n";
 
// close the FTP stream
ftp_close($conn_id);
?>
firekiller15Asked:
Who is Participating?
 
RoonaanConnect With a Mentor Commented:
Shouldn_t $ftp_path be 'spencer/test.txt';
0
 
firekiller15Author Commented:
ohh you mean i need to create a text file inorder to upload the file
0
 
RoonaanCommented:
No,

You need to specify the full new filename, instead of only the directory where the file should be put.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.