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

  • Home
  • SEARCH
  • 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 6157969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:52:29+00:00 2026-05-23T20:52:29+00:00

Once again I need some much appreciated help from the experts :) I am

  • 0

Once again I need some much appreciated help from the experts 🙂
I am trying to use PHP’s FTP functions to upload a file to the server via a web form, I’ve spent the day Googling for a simple tutorial but most seem to expect a certain level of understanding about the process. So, I’ve found an example that I believe will do the job for me, but I frankly don’t understand how to concoct the ftp path?

Here’s the script in it’s entirety (I found it on Tech Republic)

<?
// get FTP accessparameters
$host = "<URL of site>";
$user = "user@<URL of site>";
$pass = "<PASSWORD>";
$destDir= "www/uploads/files/";
$workDir= "/usr/local/temp"; // define this as perlocal system
// get temporary file namefor the uploaded file
$tmpName= basename($_FILES['ufile']['tmp_name']);
// copy uploaded file intocurrent directory
move_uploaded_file($_FILES['ufile']['tmp_name'], $workDir."/".$tmpName) or die("Cannot move uploaded file toworking directory");
// open connection
$conn= ftp_connect($host) or die ("Cannot initiate connection tohost");
// send access parameters
ftp_login($conn,$user, $pass) or die("Cannot login");
// perform file upload
$upload = ftp_put($conn, $destDir."/".$_FILES['ufile']['name'], $workDir."/".$tmpName, FTP_BINARY);
// check upload status
// display message
if (!$upload) {
    echo "Cannotupload";
} else {
    echo "Uploadcomplete";
}
// close the FTP stream
ftp_close($conn);
// delete local copy ofuploaded file
unlink($workDir."/".$tmpName) or die("Cannot delete uploaded filefrom working directory -- manual deletion recommended");
?>

At the moment it’s failing with “Cannot move uploaded file to working directory” – so I am assuming that the path is incorrect.
When this particular user connects via ftp, their home directory is “files”.

I appreciate the advice.

Answer below

I have it working.
Because the users home directory is “files” it required that inside this directory there be two further directories called “file” and “temp”
I altered the code above to:-

$destDir= "files";
$workDir= "temp";

and found an example of an ftp connection string to work backwards from so that the code generated the correct format.
Easy when you know how!

  • 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-05-23T20:52:30+00:00Added an answer on May 23, 2026 at 8:52 pm

    I have it working. Because the users home directory is “files” it required that inside this directory there be two further directories called “file” and “temp” I altered the code above to:-

    $destDir= "files";
    $workDir= "temp";
    

    and found an example of an ftp connection string to work backwards from so that the code generated the correct format. Easy when you know how!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once again I need some help. I'm working with a table that contains 3
I need your expertise once again. I have a java class that searches a
Hey all, i am new at everything VB.net/ASP.net so i need some help with
Once again one of those: Is there an easier built-in way of doing things
Once again a very beginner-ish question, but here I go: I would like to
Hey all i am in need of some helpful tips/advice on how to go
once again I've got a question. Since I am using Google Web Toolkit (GWT)
I need somehow to determine whether some TDateTime value is within the Daylight Saving
Once I've created a variable in the immediate window in C# (VS2008), is there
Once a user starts a session (or logs in, for a registered user, to

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.