GithubHelp home page GithubHelp logo

laravel-ftp's Introduction

Hi there 👋 I'm Harish!

I am a full stack web developer and FLOSS supporter specialized in Javascript/NodeJS and web technologies.

🌐 Check out my website

Languages and Tools:

laravel-ftp's People

Contributors

eduardbess avatar harishanchu avatar lsowen avatar mnabialek avatar phazei avatar tomas-novotny avatar tufanbarisyildirim avatar yahoo-ptz avatar yamenarahman avatar zwaen91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-ftp's Issues

getDirListing returns false

Hello, I was wondering why when I use getDirListing() method it returns me false, however when I use makeDir('directory-name') it does create the directory successfully. Can you help me?

SFTP Server not connecting

Hi Harish,

Thanks for such a useful library.

I am using it in my application. It is working good to connect FTP Server.
But it is not working to connect SFTP server(I am using port#22).

It is showing following error.
ftp_login() expects parameter 1 to be resource, boolean given.
How to connect it to SFTP server.

Thanks..

Code kept timing out at the ftp_nlist() command

Creating a script to connect to an FTP server. That should be simple and trivial, right? The important code that they were using looked like:

$server_file = Ftp::connection()->getDirListing('product/catalog');

Unfortunately the code kept timing out at the ftp_nlist() command. After a few minutes the script would timeout and return a warning:

Warning: ftp_nlist() [function.ftp-nlist]: php_connect_nonb() failed: Operation now in progress (115)

Limit readFile to x lines

Would it be good to be able to limit how many lines can be read through files and be sorted from LAST line or FIRST line too

FTP::connection()->readFile($fileFrom)->limit(30)->DESC

An example of usage is when you have a large monitoring log on the server and you don't want to read the whole file but only LAST 100 lines.

Fluent Interface?

Can you provide a fluent interface like this?

FTP::connection('foo')->changeDir('bar')
                      ->makeDir('abc')
                      ->changeDir('abc')
                      ->uploadFile('foobar.txt', 'barfoo.txt')
                      ->getDirListing();

It's not a necessity but I think this would improve the ease of use.

Greetings from Germany
Christian

ftp_nlist and extra parameters

Depending on the FTP server configuration, some of us might not want to include any extra parameters to the getDirListing function.

In that case, it seems that the generated folder string will have an empty space at the beginning which, in my case will lead into not reading the contents of the FTP folder.

SFTP?

in the connections array in my ftp.php, is there a way to stipulate an SFTP connection?

Test connection

Hi,

How can I catch if the ftp connection failed? I get the following error:

ErrorException in Ftp.php line 48:
ftp_login(): Login authentication failed

But I want to get a false or something like that so I can check if it has failed.

Can not install the app

When I try to install it I get the following error:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: remove laravel/framework v5.0.33
- Conclusion: don't install laravel/framework v5.0.33
- Conclusion: don't install laravel/framework v5.0.32
- Conclusion: don't install laravel/framework v5.0.31
- Conclusion: don't install laravel/framework 5.0.30
- Conclusion: don't install laravel/framework v5.0.29
- Conclusion: don't install laravel/framework v5.0.28
- Conclusion: don't install laravel/framework v5.0.27
- Conclusion: don't install laravel/framework v5.0.26
- Conclusion: don't install laravel/framework v5.0.25
- Conclusion: don't install laravel/framework v5.0.24
- Conclusion: don't install laravel/framework v5.0.23
- Conclusion: don't install laravel/framework v5.0.22
- Conclusion: don't install laravel/framework v5.0.21
- Conclusion: don't install laravel/framework v5.0.20
- Conclusion: don't install laravel/framework v5.0.19
- Conclusion: don't install laravel/framework v5.0.18
- Conclusion: don't install laravel/framework v5.0.17
- Conclusion: don't install laravel/framework v5.0.16
- Conclusion: don't install laravel/framework v5.0.15
- Conclusion: don't install laravel/framework v5.0.14
- Conclusion: don't install laravel/framework v5.0.13
- Conclusion: don't install laravel/framework v5.0.12
- Conclusion: don't install laravel/framework v5.0.11
- Conclusion: don't install laravel/framework v5.0.10
- Conclusion: don't install laravel/framework v5.0.9
- Conclusion: don't install laravel/framework v5.0.8
- Conclusion: don't install laravel/framework v5.0.7
- Conclusion: don't install laravel/framework v5.0.6
- Conclusion: don't install laravel/framework v5.0.5
- Conclusion: don't install laravel/framework v5.0.4
- Conclusion: don't install laravel/framework v5.0.3
- Conclusion: don't install laravel/framework v5.0.2
- Conclusion: don't install laravel/framework v5.0.1
- caffeinated/themes dev-master requires illuminate/config 5.1.* -> satisfiable by illuminate/config[v5.1.1, v5.1.2, v5.1.6].
- caffeinated/themes dev-master requires illuminate/config 5.1.* -> satisfiable by illuminate/config[v5.1.1, v5.1.2, v5.1.6].
- don't install illuminate/config v5.1.1|don't install laravel/framework v5.0.0
- don't install illuminate/config v5.1.2|don't install laravel/framework v5.0.0
- don't install illuminate/config v5.1.6|don't install laravel/framework v5.0.0
- Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[5.0.30, v5.0.0, v5.0.1, v5.0.10, v5.0.11, v5.0.12, v5.0.13, v5.0.14, v5.0.15, v5.0.16, v5.0.17, v5.0.18, v5.0.19, v5.0.2, v5.0.20, v5.0.21, v5.0.22, v5.0.23, v5.0.24, v5.0.25, v5.0.26, v5.0.27, v5.0.28, v5.0.29, v5.0.3, v5.0.31, v5.0.32, v5.0.33, v5.0.4, v5.0.5, v5.0.6, v5.0.7, v5.0.8, v5.0.9].
- Installation request for caffeinated/themes dev-master -> satisfiable by caffeinated/themes[dev-master].

Any help with this issue will be appreciated

Laravel 5.4 support

Call to undefined method Illuminate\Foundation\Application::share() in /www/vendor/anchu/ftp/src/Anchu/Ftp/FtpServiceProvider.php:33

Laravel 5.4 removed the share() method and the use of singleton is now the right way.

Documentation is Wrong for version 1.0.0

I have downloaded the package in my laravel 4.2 application and I have to look at the source code to see what's going on. Because in the documentation all the methods are static but not in the source code. So please fix it.

Ftp [default] not configured.

Hello Mr Haris
I got an error, the error said
InvalidArgumentException in FtpManager.php line 59: Ftp [default] not configured.

but I already configure on config/ftp.php

'default' => 'connection1'

'connections' => array(

        'connection1' => array(
            'host'   => 'localhost',
            'port'  => 14147,
            'username' => 'user1',
            'password'   => 'admin',
            'passive'   => false,
        ),
)

in my controller

$listing = FTP::connection('default')->getDirListing('ftp://192.168.100.2');
dd($listing);

is there something wrong with my code, I wanna access file on my ftp via laravel, is that possible?
thanks for answer, I'm sorry for bad English :)

Read the content of a file on the server.

Hi, I'm working on a application that have to deal with XML files from a server, but I don't need to download them, only read the content, is there a way to it with this provider?

Detailed listing for Windows servers fails

The FTP class blindly assumes that the server it's connected to supports Unix style directory listing. This is not the case for non-configured Windows FTP servers. ftp_rawlist returns a list like this:

[
    "05-30-16  14:00       <DIR>          Network",
    "05-30-16  14:30                   52 File.txt",
    "05-30-16  16:29       <DIR>          Temp",
    "05-30-16  16:29       <DIR>          Windows"
]

Here the result from ftp_rawlist is split by a number of spaces and then the list construct is used to extract the results into a variable. With Windows-style directory listings, this results in an Undefined Offset: 4

can't download

$listing = FTP::connection()->getDirListing("cdr");
$file = $listing[0];
$path = storage_path('app\file');
$download = FTP::connection()->downloadFile($file, $path);

But nothing in the file dir

Documentation

When we try to override the config on the fly, doing as stated in the documantation will throw an exception:
Error in ftp: ftp_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known

The problem is that we can't specify the name of the connection 'key', because if you do so the class FtpManager will end up with a empty config, therefore in class Ftp will not be possible to make the connection.

This is wrong and will not work, as it is in documentation:
Config::set('ftp::connections.key', array(
'host' => '',
'username' => '',
'password' => '',
'passive' => false,
));

This will work:
Config::set('ftp::connections', array(
'key' => array(
'host' => '',
'username' => '',
'password' => '',
'passive' => false
),
));

Many thanks for this very useful library :)

Mistake in documentation

I think uploadFile needs a string (path to file), not an open file pointer. The documentation specifies this incorrectly.

uploadFile($fileFrom, $fileTo) - Uploads the data from a file pointer to a remote file on the FTP server.

$fileFrom: An open file pointer on the local file. Reading stops at end of file.
$fileTo: The remote file path.

Ftp [XXXX] not configured.

whenever I try to connect to any ftp i get this message,
My Code
use Anchu\Ftp\Facades\Ftp; public function CreateXXXConnection() { $listing = FTP::connection('xxx')->getDirListing(); return $listing; }

and all ftp config set in the config.php file

Why not use Flysystem?

Is there a reason to use this library instead of the built-in Flysystem in Laravel 5? I just added this to my disks in filesystems.php:

    'ftp' => [
        'driver' => 'ftp',
        'host' => '...',
        'port' => 21,
        'timeout' => 20,
        'username' => '...',
        'password' => '...',
        'passive' => true,
    ],

And now I can open, read and write files to my heart's content with Storage::disk('ftp')->... in the same way as any other filesystem!

Maybe this library is only needed for legacy reasons? Should that be added to the README?

uploadFile error

When use uploadFile function,exception like this:
ErrorException: ftp_fput(): php_connect_nonb() failed: Operation now in progress (115)

I was set config passive is true

Dealing with compressed files and .ap extension

Firstly great work!
This question maybe isn't considered as a bug or problem with your package, I just want help. I have ftp connection and in it there is a .zip file, the compressed file contains a .app file which holds some records for products with their sku's and prices and this .app extension I've never deal with before.

I need to acces that .app file, what should I go for ?

Any help is really appreciated.

Request: Timeout setting in config

Hello,
I've run into issues downloading files over slow VPN connections that I believe may be caused by timeouts. No errors are returned, but if the file was already in place it is removed, but not replaced.

Thanks!

How do I set the permissions on a newly created directory

I am using the following to create a new directory to hold uploaded files

$path = 'code/LENDA/public/files_loans/' . $crop_year . '_' . $loan->id;
FTP::connection()->makeDir($path);

How do I set the permissions on that folder to allow uploads? The docs only talk about setting permission on a file.

Thanks!!!
Jon

Bug with filenames with more than one space

Hi, I've found a bug when trying to import files with more that one space in the name.

Here is a fix :

public function getDirListingDetailed($directory = '.')
{
if (is_array($children = @ftp_rawlist($this->connectionId, $directory))) {

        $items = array();

        foreach ($children as $child) {
            $chunks = preg_split("/\s+/", substr($child,0,61));
            $name = substr($child,62);

            list(
                $item['rights'],
                $item['number'],
                $item['user'],
                $item['group'],
                $item['size'],
                $item['month'],
                $item['day'],
                $item['time']
            ) = $chunks;

            $item['type'] = $chunks[0]{0} === 'd' ? static::TYPE_DIR : static::TYPE_FILE;
            array_splice($chunks, 0, 8);

            $items[implode(" ", $chunks).$name] = $item;
        }
        return $items;
    }

    return false;

}

Coould you include this fix?

Thanks!!

Class FTP not found

Hello,
this package works great with eg the size method or the create_dir method, but when I try to upload a file to my FTP server, it returns an error saying "Class 'FTP' not found".
Does anyone know what the problem might be here?
Thanks

my code:

$name=Input::get('name');
$file=Input::file('file');
$tmp_path=$file->getRealPath();
$file_ext=$file->getClientOriginalExtension();

$new_file_name=$name.".".$file_ext;
$new_path="tasks/".$name."/new/".$new_file_name;
$upload=FTP::connection()->uploadFile($tmp_path,$new_path);

if($upload){
    return "file was uploaded";
}

Download a large file to the browser directly

Hi, nice library. I am trying to download a large file, an PSD file, that is in a remote ftp server that I owned. I'm developing a web app that can download directly to the user's browser. Is there a way to do this, without download it in my server and then to the user?

Thanks!

Upload file in loop

Hello,

I want to upload files with a loop. But I have create a loop:

$i = 1;
foreach(glob(storage_path().'/uploads/'.$opr.'-'.$ver.'-'.$spar.'*') as $picture) {
        echo $picture . "<br>";
    $info = pathinfo($picture);

    FTP::connection()->uploadFile($picture, 'public_html/project/'.$opr.'/images/'.$ver.$spar.'_'.$i.'.'.$info['extension']);
    $i++;
}

But it uploads only one file.
And if I debug the file list I see every file.

foreach(glob(storage_path().'/uploads/'.$opr.'-'.$ver.'-'.$spar.'*') as $picture) {
        echo $picture . "<br>";
    $info = pathinfo($picture);
}

What can I do?

No upload method...

I am using this laravel package, but only version 1.0.0 for my Laravel 4 project. I have tried to use uploadFile method within this method below:


private function uploadToStaticServer($year, $month, $day, $filename, $fileFrom, $big=true){

         if($big){
             Log::debug("Starting big image upload to static server...");
             FTP::connection()->changeDir('big');
         } else {
             Log::debug("Starting small image upload to static server...");
             FTP::connection()->changeDir('small');
         }

         //Change or create&change to year dir
         if(! FTP::connection()->changeDir($year)){
             Log::debug("Didn't change to year dir, we need to create it...");
             $isYearDirMade = FTP::connection()->makeDir($year);
             FTP::connection()->changeDir($year);
             Log::debug("Is year dir made: " . $isYearDirMade);
         } else {
             Log::debug("Changed to year dir, let's continue...");
         }

         //Change or create&change to month dir
         if(! FTP::connection()->changeDir($month)){
             Log::debug("Didn't change to month dir, we need to create it...");
             $isMonthDirMade = FTP::connection()->makeDir($month);
             FTP::connection()->changeDir($month);
             Log::debug("Is month dir made: " . $isMonthDirMade);
         } else {
             Log::debug("Changed to month dir, let's continue...");
         }

         //Change or create&change to month dir
         if(! FTP::connection()->changeDir($day)){
             Log::debug("Didn't change to day dir, we need to create it...");
             $isDayDirMade = FTP::connection()->makeDir($day);
             FTP::connection()->changeDir($day);
             Log::debug("Is day dir made: " . $isDayDirMade);
         } else {
             Log::debug("Changed to day dir, let's continue...");
         }

         //Try upload
         $fileTo = $year . '/' . $month . '/' . $day . '/' . $filename;
         if(FTP::uploadFile($fileFrom, $fileTo)){
             Log::debug("File uploaded OK. Go check it...");
         }
     }

This is the error I get: http://note.io/1FgLfN6

I don't know what is wrong, as all other methods are working and i use your namespace aliased to FTP in the class where this method is.

Where to add dynamic FTP connections?

I am using L 5.2, I want to create dynamic FTP connections by getting credentials from DB and create multiple instances,
Where to add dynamic FTP Config ?

Dependency Injection

How would I inject the FTP class into my own class via type hinting in the constructor? Bearing in mind its using an alias.
If I try the following approach, I get hit with a dependency resolution error.

eg:

use App\Something
...

public function __construct(Something $something)
    {
        $this->something = $something;
    }

Adding Dynamic FTP Accounts

Hello!
Thank you for this plugin, i have a little question. I'm trying to add dynamic ftp accounts like this, in routes.php:

Route::get('/', function ()
{
Config::set('test', array(
'host' => 'ip',
'username' => 'user',
'port' => 21,
'password' => 'pass.',
'passive' => false,
));
$listing = FTP::connection('test')->getDirListing();
return $listing;
});

Giving this result:

Ftp [test] not configured.

How can i use this?

try/catch on PHP native FTP functions

Hi!

It would be great if you could add try/catch to all PHP native FTP functions (like ftp_chdir, ftp_mkdir, etc).

I'm currently using the changeDir function to detect if the resource is a folder or a file (if can't ftp_chdir on it, has to be a file)

Kind Regards

Use with Lumen?

Hello,

I've got a Lumen app that I need an FTP package for. I installed this one and am running in to an error.

When running php artisan vendor:publish, I get the following:

PHP Fatal error:  Call to undefined function Anchu\Ftp\config_path() in vendor/anchu/ftp/src/Anchu/Ftp/FtpServiceProvider.php on line 22

I tried copying vendor/anchu/ftp/src/config/config.php to config/ftp.php & filled in the details, but I get the same error when trying to use the package with FTP::connection()->getDirListing(); (this time with stack trace):

PHP Fatal error:  Call to undefined function Anchu\Ftp\config_path() in vendor/anchu/ftp/src/Anchu/Ftp/FtpServiceProvider.php on line 22
PHP Stack trace:
PHP   1. {main}() artisan:0
PHP   2. require() artisan:18
PHP   3. Laravel\Lumen\Application->register() bootstrap/app.php:87
PHP   4. Anchu\Ftp\FtpServiceProvider->boot() vendor/laravel/lumen-framework/src/Application.php:230

Fatal error: Call to undefined function Anchu\Ftp\config_path() in vendor/anchu/ftp/src/Anchu/Ftp/FtpServiceProvider.php on line 22

Call Stack:
    0.0003     225480   1. {main}() artisan:0
    0.0013     232032   2. require('bootstrap/app.php') artisan:18
    0.1031    2440912   3. Laravel\Lumen\Application->register() bootstrap/app.php:87
    0.1049    2456600   4. Anchu\Ftp\FtpServiceProvider->boot() vendor/laravel/lumen-framework/src/Application.php:230

I know Lumen is a subset of Laravel's functionality, so there's probably something missing, but it would be great to be able to use your package with it!

Feature Request: UploadFiles

Single file upload works great but a new connection has to be made before every file upload. UploadFiles method work make it great.

Config file naming

You closed my pull request, but it was meant to prevent the following error:
php.exe artisan vendor:publish
Can't locate path: C:\xampp\htdocs\project\laravel\vendor\rikless\laravel-ftp\src\Anchu\Ftp/../../config/config.php

Facade name

Hi there,

first of all - nice that somebody got the idea to make an FTP bundle!

What do I mean by "facade name"?
As some users also write deploy scripts for SSH it would be handier to have FTP and not Ftp.

Like:: FTP::dir('tests');

  1. looks better
  2. feels more native when writing tasks for ssh/ftp

Why it feels more native? Look at your README.md. You did it wrong there natively and used FTP:: :)

If you don't accept its fine. Just been curious to tell you.

Best regards
Steven.

Phalcon FTP

Hi harishanchu

I want using library Laravel-FTP to phalconphp but i don't know do that.

You can help me.

Thank you.

Why its not upload file greater then 2mb

I want to upload a mp3 file with ftp becouse my server config is set to max_file_upload 2mb and i am anable to upload file greater then 2mb so i want to upload its by ftp is it possible?

Feature: overriding download mode

Hi!

With Ubuntu Server I'm getting an error for downloading files in ascii mode (550 SIZE). It would be awesome to be able to override the mode with the download function, e.g. something like this:

public function downloadFile($fileFrom, $fileTo, $mode=null)
    {
        $fileInfos = explode('.', $fileFrom);
        $extension = end($fileInfos);
        if($mode == null) {
           $mode = $this->findTransferModeForExtension($extension);
       }
        try {
            if (ftp_get($this->connectionId, $fileTo, $fileFrom, $mode, 0))
                return true;
            else
                return false;
        } catch(\Exception $e) {
            return false;
        }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.