Jump to content

upload big file


web_master

Recommended Posts

hi everyone,

 

I need upload a big files on server with PHP. I find one „solution” on internet and that is sending file via FTP with php. I try it but its dont work. Maybe there is no given a passive mode... but the scrip wont connect to ftp.

Uploading big file using FTP is a good method? Or is there some other (simple) solution to upload big files with php?

 

here is the script what I try to use

 

<?php
ob_start();

if (isset($_POST['submitted']))
{
// get FTP access parameters
$host = 'localhost';
$user = 'user';
$pass = 'password';
$destDir = 'public_html/video';
$workDir = 'public_html/tmp'; // define this as per local system

// get temporary file name for the uploaded file
$tmpName = basename($_FILES['file']['tmp_name']);

// copy uploaded file into current directory
move_uploaded_file($_FILES['file']['tmp_name'], $workDir."/".$tmpName)
or die("Cannot move uploaded file to working directory");

// open connection
$conn = ftp_connect($host) or die ("Cannot initiate connection to
host");

// send access parameters
ftp_login($conn, $user, $pass) or die("Cannot login");

// perform file upload
$upload = ftp_put($conn, $destDir."/".$_FILES['file']['name'],
$workDir."/".$tmpName, FTP_BINARY);

// check upload status
// display message
if (!$upload) {
  echo "Cannot upload";
} else {
  echo "Upload complete";
}

// close the FTP stream
ftp_close($conn);

// delete local copy of uploaded file
unlink($workDir."/".$tmpName) or die("Cannot delete uploaded
file from working directory -- manual deletion recommended");
}
?>

<form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
File <br />
<input type="file" name="file" /><p />
<input type="submit" name="submit" value="Upload File" />
<input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
    ob_end_flush();
?>

 

thanks in advanced

 

T

Link to comment
Share on other sites

Where are you trying to upload the file FROM and where are you trying to upload the file TO? What exact problem are you having with large files and how large are the files that don't work?

 

Using a web based HTML form, implies that you are uploading the file from a client/browser to your server where your .php code is located. Adding ftp_xxxxx() statements in your code code implies that you want to send that file, after it has been uploaded to your server, to an different server by using FTP to transfer it. If the file isn't uploading to your server in the first place, trying to use FTP to transfer it somewhere else doesn't make an sense.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.