ftp_alloc

(PHP 5, PHP 7, PHP 8)

ftp_allocAllocates space for a file to be uploaded

Description

ftp_alloc(FTP\Connection $ftp, int $size, string &$response = null): bool

Sends an ALLO command to the remote FTP server to allocate space for a file to be uploaded.

Note:

Many FTP servers do not support this command. These servers may return a failure code (false) indicating the command is not supported or a success code (true) to indicate that pre-allocation is not necessary and the client should continue as though the operation were successful. Because of this, it may be best to reserve this function for servers which explicitly require preallocation.

Parameters

ftp

An FTP\Connection instance.

size

The number of bytes to allocate.

response

A textual representation of the servers response will be returned by reference in response if a variable is provided.

Return Values

Returns true on success or false on failure.

Changelog

Version Description
8.1.0 The ftp parameter expects an FTP\Connection instance now; previously, a resource was expected.

Examples

Example #1 ftp_alloc() example

<?php

$file 
"/home/user/myfile";

// connect to the server
$ftp ftp_connect('ftp.example.com');
$login_result ftp_login($ftp'anonymous''user@example.com');

if (
ftp_alloc($ftpfilesize($file), $result)) {
  echo 
"Space successfully allocated on server.  Sending $file.\n";
  
ftp_put($ftp'/incoming/myfile'$fileFTP_BINARY);
} else {
  echo 
"Unable to allocate space on server.  Server said: $result\n";
}

ftp_close($ftp);

?>

See Also

  • ftp_put() - Uploads a file to the FTP server
  • ftp_fput() - Uploads from an open file to the FTP server

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

PHP cURL Tutorial: Using cURL to Make HTTP Requests

cURL is a powerful PHP extension that allows you to communicate with different servers using various protocols, including HTTP, HTTPS, FTP, and more. ...

TheMax

Autor : TheMax
Category: PHP-Tutorials

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial