Forum Moderators: coopster
I am makng a video uplaod script,using FTP functions of php. but each time it is givng error that upload failed.
when i host script to local sever it is uploading files to my web server. But when i hosted script on my web server and runs it each time it is falling in condition that,file uplad failed.
below is the code that, i am using in script
<?
if(isset($_POST['submit']))
{
$conn_id = ftp_connect('myserver.com');// login with username and password
$login_result = ftp_login($conn_id,'usrName', 'password');// check connection
if ((!$conn_id) ¦¦ (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected to server!";
}// upload the file
$file = $_POST['userfile'];$dir = "/public_html/$file";
$upload = ftp_put($conn_id, $dir, "$file", FTP_BINARY);// check upload status
if (!$upload)
{
echo "FTP upload has failed!";
}
else
{
echo "Uploaded $file to myserver.com";
}
// close the FTP stream */
ftp_close($conn_id);
?>
Can any body help me in debug it.
Regards,
Vineet
You will have a dir with name /public_html/my_name.mpg?
I think you mean $dir = "/public_html/"; :)
In that case try $dir = dir("/public_html/");
Also check read/write mode in your folder, else try to chmod(0777) it.
Try to use something like
if (is_dir($dir))
{
// execute
}
else
{
echo $dir." is not a folder";
}
in php manual, there is a user contributed function that dos what you want
[gr.php.net...]
(one of the first ones from user kiwo1)
Hope this helps