robcrozier Posted October 29, 2008 Share Posted October 29, 2008 Hi everyone, what i'm trying to do is allow a user to upload a file to the server via FTP using PHP. I have chosen to do it this way so that the file permissions are not set to apache when the file is uploaded, instead they will be set to me (the owner) so that they can be remotely opened etc later on. Here's what i have so far: $ftp_server = "******"; $ftp_user_name = "******"; $ftp_user_pass = "******"; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); ftp_put($conn_id, $target, $_FILES['file']['tmp_name'], FTP_BINARY); However i keep getting this error message: ftp_put() [function.ftp-put]: path/to/file/name.jpg: No such file or directory in path/to/php/file on line 91 Can anyone help? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/ Share on other sites More sharing options...
rhodesa Posted October 29, 2008 Share Posted October 29, 2008 how do you set the value of $target? Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/#findComment-677522 Share on other sites More sharing options...
robcrozier Posted October 29, 2008 Author Share Posted October 29, 2008 The target is set like this: $target = "../media/siteImgs/store/products/".$file; Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/#findComment-677537 Share on other sites More sharing options...
rhodesa Posted October 29, 2008 Share Posted October 29, 2008 if you put this line right before the ftp_put(): echo $target.'<br>'; echo $_FILES['file']['tmp_name'].'<br>'; what does the output look like? Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/#findComment-677541 Share on other sites More sharing options...
robcrozier Posted October 29, 2008 Author Share Posted October 29, 2008 Here's what's output: ../path/to/file/targetFileName.jpg fileName.JPG Thanks mate Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/#findComment-677545 Share on other sites More sharing options...
rhodesa Posted October 29, 2008 Share Posted October 29, 2008 well....$target isn't getting set properly then. give your script a look over again and see if you can find it. if you post the entire script, i can help you try and find the problem Quote Link to comment https://forums.phpfreaks.com/topic/130594-uploading-a-file-via-ftp/#findComment-677567 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.