Try upload videofile - php

I use Laravel 5.4 and I try upload video file. Image file upload successfully.
$video = Request::file('video_file')) {
$fullName = 'videos/'.uniqid().time().'.'.$video->getClientOriginalExtension();
Storage::disk()->put($fullName, $video);
But it didn't work. When I try get information about file - size = 0
What I do wrong?

There’s a limit on the amount of data you can send in a POST request. If you exceed that limit, PHP will return zero as the size of the file.
Instead, you’ll need to upload the file in chunks. If you’re using something like Amazon Web Services, they have a JavaScript SDK that will handle multi-part uploads for you: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property

Check out http://php.net/manual/en/ini.core.php#ini.post-max-size
PHP has a default max_post_size of 8mb I believe, anything larger than that will not go through. There is also a upload_max_filesize that you may want to check out. I'm not sure if increasing the limit is the correct answer here, as I'm not sure what complications that would bring. When we upload large Files we use blue imp's file uploader: https://github.com/blueimp/jQuery-File-Upload
It's pretty straight forward and automatically chunks the uploads for you.

Related

TYPO3: Data is not posting on select file larger than 1.5 KB to be uploaded

I need to upload files from the front in my plugin. I got the success with it, but then now I have an issue during uploading larger file than 1.5 KB. Whenever I select file larger than 1.5 KB, i get error:
1298012500: Required argument "newRockupload" is not set for Rock\RockUpload\Controller\RockuploadController->create.
So i have put this code in initializeCreateAction() of controller to debug:
$arguments = $this->request->getArguments();
DebuggerUtility::var_dump($arguments);
exit;
So whenever i select file which has lower size than 1.5 KB, I get posted data successfully in controller:
And whenever i select larger file than 1.5 KB i am getting nothing like this:
I tried and surfed lot. Need Help..
As it mentioned in the comments, this is probably an issue with the URL you are trying to send.
The parameter is not there in the TYPO3, (maybe not even on the server side.) I guess something is wrong with your fluid form.
You should inspect your request.
You can check it in your browser / apache access log / even with a debugger in the TYPO3 code.
Probably you are trying to send the data of the file in the Request Header instead of the Request Body.
You have probably some characters already in your URL so a file > 1.5 kb exceeds the limit of around 2000 characters in the url.
See also here about the limit of the url:
What is the maximum length of a URL in different browsers?

Request Entity Too Large with small files

I know there are many questions about Request Entity Too Large on internet but i could not find right answer for my problem ;)
I`m using HTML file input tag to let users upload their images .
<input type = 'file' class = 'upload-pic' accept='image/*' id ='Fuploader' name = 'pro-pic'><br>
There is nothing wrong with files less than 2 MB which is allowed by my site
But the problem is if some one decide to upload larger file like 5.10 MB , i can handle it by php and warn user that this file is too large
if($_FILES['pro-pic']['size'] > 2000000)
{
die("TOO LARGE");
}
But my problem is by uploading 5.10 MB file , Request entity too large error will be lunched and rest of my php code won`t work
I have checked post_max_size and upload_max_filesize they are both set to 8MB
But i get Error on 5.10MB !
And I need to find way to handle files even larger than 8MB because there is no way to guess what user may try to upload ;) and i don`t want them to get dirty and broken page because of REQUEST ENTITY TOO LARGE ERROR
Is there any way too fully disable this Error Or set upload_max_filesize and post_max_size to infinity ?
You need to set SecRequestBodyAccess Off.
Check the link i have given ..it would help you
https://serverfault.com/questions/402630/http-error-413-request-entity-too-large

base64 Pic Upload and Crop Situation PHP

I am trying to take a pic upload from a mobile device to a server. We are building with PhoneGap (Javascript), so we are having turn it into a string in order to send it to the server. I am having problems once I receive it, to turn it back into a readable image file.
Simply put, I need to take a string and a file name sent to me, decode it, convert it into a .png, then crop it into a circular image.
This is what I have going on currently
if (isset($_POST['file']))
{
//Result variable
$result = false;
$pic = base64_decode($_POST['file']);
$filename = $_POST['filename'];
if (strlen($pic) > 9 )
{
$fh = fopen("/var/www/pics/events/".$filename, 'w') or die("can't open file");
fwrite($fh, $pic);
fclose($fh);
}
}
I think I can get the rest of the code to work if I can figure out what I am doing wrong here that makes it not save properly as a image file? The file uploads correctly, but it stores with out an extension, and when I point to it in my browser, it comes up like it is supposed to be an image file, but never displays the image. That little broken picture icon with the colored shapes is what I get when I direct to it's location.
Do I need to be aware of what image type is being sent during this process at all? How is it knowing if it is a .gif, .jpg/jpeg, .png, etc...?
Thanks in advance for any help!
Nathan
For Security reasons you should sanitize the file name to prevent directory traversal.
On a brighter note, make sure the file is saved with the proper extension; if you are already saving with the correct extension you could have an encoding issue from the app.
If neither of the previous possibilities are the case make sure that your String Size does not exceed the maximum POST size limit in your php.ini; if that is the case increase the size limit.

empty $_POST and $_FILE variable when uploading large files

I was trying to upload a file which is 20MB in size. Now default form upload size is 8MB. When I upload such a file i get $_POST and $_FILE variables empty. Now I want to put a check on file size. If I get both these variables empty, how can I put such a check ?? Please give me suggestions
Barring any code errors, its most likely your 20MB exceeds your upload limit.
Change this permanently from your php.ini file.
Use
ini_set("upload_max_filesize", "30M");
to set your max upload size for that session only. And for POST
Use this
ini_set("post_max_size", "30M");
To check the sizes
echo ini_get("post_max_size") . "\n";
echo ini_get("upload_max_filesize");
No idea what you actually want. But you can probe the recieved content size using:
$_SERVER["CONTENT_LENGTH"]
This should tell how big the POST request body would have been. (The number might be higher than the actual received content, in case of an aborted upload.)
Checkout php://input, the allowed 8mb part of it should be there.
For example echo file_get_contents('php://input');
You can dynamically set your max file size for upload.
write down below statement in your upload function where you are trying to upload file.
this will enhance limit up to 50 MB
ini_set("upload_max_filesize", "50M");
If you want to check file variables, you can user alternative HTTP_POST_FILES
$theFileSize = $HTTP_POST_FILES['file']['size'];
Hope this may help you.
Thanks.
Use MAX_FILE_SIZE as a hidden input field, this will stop the user waiting if the file is larger than the limit and won't execute your code so the variables won't be empty...
The MAX_FILE_SIZE hidden field (measured in bytes) must precede the
file input field, and its value is the maximum filesize accepted by
PHP. This form element should always be used as it saves users the
trouble of waiting for a big file being transferred only to find that
it was too large and the transfer failed. Keep in mind: fooling this
setting on the browser side is quite easy, so never rely on files with
a greater size being blocked by this feature. It is merely a
convenience feature for users on the client side of the application.
The PHP settings (on the server side) for maximum-size, however,
cannot be fooled.
http://www.php.net/manual/en/features.file-upload.post-method.php

Problem with Flash PHP upload

I am using a script to upload photo (written by my own) which allow user to select more than 1 files, using Flash.
When user click upload, as3 will post the upload file to upload.php, resize it, and save it one by one.
The problem:
In production server, if I am uploading many photos and the photos size are very large, >2MB, the uploading progress just stuck in halfway, only the first few photos successfully uploaded.
What I have found out:
If I tried with smaller size photos, or if I disabled the resizing script in upload.php, there are no problem at all.Furthermore, the script work fine in my localhost with newer processor compared to the problematic server with older model)
The resize script is simple. It just check whether the image resolution is large, and use imagecopyresampled() to resize the image if needed.
I tried to unset image resource in upload.php to free up memory but it doesn't help.
What else could be the problem?
If I remember right, there is a 2mb upload limit in php, you can change it in the php.ini file.
I solved the problem.
It happens when I use code like this in AS3:
for(var i:Number = 0; i< fileList.length; i++) {
fileList[i].upload(new URLRequest(param.uploadURL+"&sessionid="+param.session_id));
}
The code seems like pushing upload.php script in very tedious way.
I made changes to both my AS3 and JS, so that JS call to AS3 upload() function only everytime a file upload is completed (from event listener EVENT.COMPLETE)
By making so, AS3 wont call for upload.php synchronously for multiple files. Instead, it wait for a file completed the upload, then call for another upload for the next file.

Categories