I read every post about this issue here but nothing helped me. My problem is that my html form not putting anything in file path if the file is bigger then 1.5 MB. For example, if i upload normal size file it's echo the file temp path, but if i upload a bigger file (say 4MB) it's just show me no error but i can see an empty file on the server. I tried to set the values in php.ini and created .htacces file with all the correct values, but nothing helped.
My code is:
<form method="post" action="test2.php" enctype="multipart/form-data">
<div>
<label for="upload">Select file</label>
<input type="hidden" name="MAX_FILE_SIZE" value="1024000">
<input name="upload" type="file" />
<input type="submit" name="Submit" value="Upload" />
</div>
</form>
<?php
if (isset($_POST['Submit'])) {
if (!empty($_FILES['upload']['name'])) {
$ch = curl_init();
$localfile = $_FILES['upload']['tmp_name'];
echo $localfile."</br></br>" ;
$fp = fopen($localfile, 'r');
curl_setopt($ch, CURLOPT_URL, 'ftp://ans.projects.jce.ac.il/public_ftp/incoming/'.$_FILES['upload']['name']);
curl_setopt($ch, CURLOPT_USERPWD, "user:password");
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 0);
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
$error_no = curl_errno($ch);
curl_close ($ch);
if ($error_no == 0) {
$error = 'File uploaded succesfully.';
} else {
$error = 'File upload error.';
}
}
else {
$error = 'Please select a file.';
}
}
echo $error;
?>
I found the solution... It was that line:
<input type="hidden" name="MAX_FILE_SIZE" value="1024000">
Once i removed it it worked. Thanks for the help everyone