In a Node.js project I have to transfer file from computer to server. I can send file if file size is small i.e. 2mb but unable to send file if it is more than this size. Here is my code as follows:
var url1 = 'http://beta.xxxxx.com/Xbox/xxxx/index.php/info/xxxxx';
var csvenriched = APPDATApath+'/xxxx/users/'+userId+'/programs/'+programName+'/'+foldername+'/Data_'+tmpstmp+'.csv';
var req = request.post(url1, function (err, resp, body1) {
if (err) {
console.log('REQUEST RESULTS:'+err+resp.statusCode+body1);
res.send(err); return false;
} else {
res.send(body1); return false;
}
});
var form = req.form();
form.append('file', fs.createReadStream(csvenriched));
On the PHP side where I am sending data code is as follows:
public function actionSavetestvideo() {
if (!empty($_FILES)) {
$path = Yii::$app->basePath.'/testfiles/'.$_FILES['file']['name'];
if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
return 'uploaded';
} else {
return 'error'.$_FILES["file"]["error"];
}
} else {
return $_FILES;
}
}
I know there are answers on internet in case if I have to upload file on Node.js server But in my case I have to transfer file using request
module from Node.js to PHP server.
It is working fine in case if file size is small but not if CSV file size is large.
The one thing which I have noticed that if file size is large then if (!empty($_FILES)){}
on php side went failed. So I don't think there is issue on PHP side. Please suggest what should I modify there?