Jump to content

File uploads - need the full file path


c_shelswell

Recommended Posts

Whats the best way to do this? :

I need to make a page that will allow someone to upload a large file to a server. I need to use ftp to do this as the filesize will be much larger than my hosts php setting will allow. I'm trying to use this:

[code]<form enctype="multipart/form-data" method="post" action="include/my_ftp.php">
<input name="file" type="file" size="40">
<input type="submit" name="upload" value="Upload">[/code]

to browse and select a file to upload the thing is the method to upload on my other page requires the full file path
[code]if (isset($_POST['upload']))
{
$file = ($_FILES['file']['name']);
putFile($file);


  }
}
}


function putFile($file)
{
$conn = DoConn();


if (ftp_put($conn, "/www/images/name.gif", $file, FTP_BINARY))
{
echo 'yes';
}
else
{
echo 'nope';
}
}[/code]

as far as i can find out the $_FILES variable won't ever get the full file name. Is there a way of doing this? or even a better way of trying to do what i'm after.

Thanks
Link to comment
https://forums.phpfreaks.com/topic/29657-file-uploads-need-the-full-file-path/
Share on other sites

Im pretty sure you need to put
[code]function putFile($file)
{
$conn = DoConn();


if (ftp_put($conn, "/www/images/name.gif", $file, FTP_BINARY))
{
echo 'yes';
}
else
{
echo 'nope';
}[/code]
Before
[code] putFile($file);[/code]
As it is trying to find something it hasnt read yet....
You have:
[code]function putFile($file)
{
$conn = DoConn();


if (ftp_put($conn, "/www/images/name.gif", $file, FTP_BINARY))
{
echo 'yes';
}
else
{
echo 'nope';
}[/code]

I think it should be
[code]function putFile($file)
{
$ftp_server = "domain.com";//This is the domain you want to FTP to.
$conn = ftp_connect($ftp_server);

if (ftp_put($conn, "/www/images/name.gif" , $file, FTP_BINARY))
{
echo 'yes';
}
else
{
echo 'nope';
}[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.