Changes to FTP via PHP function

Discussion in 'PHP' started by adamjblakey, Jul 18, 2012.

  1. #1
    Hi,

    My hosting company have stopped ftp via php so the below has stopped working. I cannot use move upload file due to the function being on a different server. I was thinking about http file transfer or any alternative you can think of but what would need to be changed on the below?

    
    function ftpupload($file, $img_tmp, $path){
    
       $message = '';
        if ($ftp = ftp_connect("119.159.171.179")) {
            if (ftp_login($ftp, "username", "pass"))
    		 {
                ftp_pasv($ftp, true);
                ftp_put($ftp, $path.$file, $img_tmp, FTP_BINARY);
    
            } else {
                die("Could not login to FTP account");
            }
        } else {
            die("Could not connect to FTP server");
        }
    	ftp_close($ftp);
    }
    
    PHP:
    Thank you in advance.
    Adam
     
    adamjblakey, Jul 18, 2012 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Get a new host. They shouldn't be disabling functions like ftp. I can see some of the basis for restricting system or exec, although they should be able to segment a hosting platform enough to still operate safely. Preventing ftp is just ridiculous. You shouldn't have to try and work around basic php functionality.
     
    jestep, Jul 18, 2012 IP
  3. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #3
    It appears from closer inspection that the problem is not due to the restriction of FTP via PHP but a limitation of the amount of connections being made. What seems to happen is a user uploads several images via the above function and then it slows right down or even comes to a stand still. Is there any way around this?
     
    adamjblakey, Jul 20, 2012 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    How large are the images? It sounds like this may be a bandwidth issue.
     
    jestep, Jul 20, 2012 IP
  5. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Very small, thats the strange thing. They are only about 30kb each.
     
    adamjblakey, Jul 20, 2012 IP