-1

I have a simple form used for uploading a video file. The files seem to upload fine, but when I look into destination folder, it isn't there.

So, the problem is moving the uploaded file. Searching where the issue could be, I tried to catch the values of name and temp name of $_FILES and I discovered that the temp name wasn't set. So, in my PHP code:

$videoName     = $_FILES['file']['name'];
$videoTempName = $_FILES['file']['tmp_name'];

$response['videoName'] = $videoName; // OK, it returns "video.mp4" which is the name of my example file.
$response['videoTempName'] = $videoTempName; // Here is my problem

echo json_encode($response);

An important thing that you should know is that I'm using WAMP Server in Windows 10. I suspect that the issue is about there because I've used the same code in remote servers without errors.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Marcelo J Forclaz
  • 718
  • 1
  • 8
  • 27
  • Possible duplicate of: https://stackoverflow.com/questions/30358737/php-file-upload-error-tmp-name-is-empty – Sanjay Rathod Aug 13 '17 at 14:23
  • 1
    Have you checked `$_FILES['file']['error']`? – M. Eriksson Aug 13 '17 at 14:24
  • 1
    There is a chance you are uploading a file larger than upload_max_filesize (in php.ini) – Andreas Aug 13 '17 at 14:28
  • @Andreas, no chances. The filesize of my example video is less than 3 MB and the WAMP Server post_max_size is setted in 256 MB – Marcelo J Forclaz Aug 13 '17 at 14:31
  • You should still check the error-param to see if there's something else that happens. – M. Eriksson Aug 13 '17 at 14:32
  • @MagnusEriksson, I did it after your comment, the `$_FILES['file']['error']` returns `1`. What it means? – Marcelo J Forclaz Aug 13 '17 at 14:34
  • That's actually what @Andreas suggested: _"Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini."_. Here are all the error codes explained: http://php.net/manual/en/features.file-upload.errors.php – M. Eriksson Aug 13 '17 at 14:37
  • My bad! I had checked the `post_max_size` but not the `upload_max_filesize` which was setted at 2 MB and my file example is greater than that. So, I changed the `upload_max_filesize` property to 256 MB in the PHP configuration of WAMP Server and it's solved the problem. Thanks @Andreas and @MagnusEriksson ! – Marcelo J Forclaz Aug 13 '17 at 14:43

1 Answers1

0

My bad! I had checked the post_max_size but not the upload_max_filesize which was set at 2 MB and my file example is greater than that. So, I changed the upload_max_filesize property to 256 MB in the PHP configuration of WAMP Server and it has solved the problem. Thanks Andreas!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Marcelo J Forclaz
  • 718
  • 1
  • 8
  • 27