tobyheywood
IS-IT--Management
Hi all,
I'm in the process of creating a script which will be used to upload an image from a webcam every 5-10 seconds to our web server.
The script so far works when I run the script from within the same directory as the file I want to upload, but not when I run it from my home directory. I am running the script as root so don't believe it is a perms issue.
The script can determine the most up to date file from the sym link in the relevant directory, so it would seem that it can't upload unless the file to be upload is in the same directory.
I would be greatful of any advice or suggested ways of getting around this.
Toby Heywood
I'm in the process of creating a script which will be used to upload an image from a webcam every 5-10 seconds to our web server.
The script so far works when I run the script from within the same directory as the file I want to upload, but not when I run it from my home directory. I am running the script as root so don't believe it is a perms issue.
The script can determine the most up to date file from the sym link in the relevant directory, so it would seem that it can't upload unless the file to be upload is in the same directory.
I would be greatful of any advice or suggested ways of getting around this.
Code:
$connid = ftp_connect($ftpserv);
$login = ftp_login ($connid, $ftpuser, $ftppass);
if (!$connid || !$login) {
echo 'Failed to connect to server\n';
} else {
echo "Connected to $ftpserv as $ftpuser\n";
}
foreach ($Camera as $val) {
$camdir = $val['LocalDir'];
$remdir = $val['RemoteDir'];
$upload_file = readlink ($camdir . 'lastsnap.jpg');
$ftp_upload = ftp_put($connid, $remdir . 'lastsnap.jpg', $upload_file, FTP_BINARY);
if ($ftp_upload) {
echo "Successfully uploaded file: $upload_file\n";
} else {
echo "Unable to upload file: $upload_file\n";
}
}
ftp_quit($connid);
Toby Heywood