With following code I tried to upload image and video file at the same time but, image file is uploading & video file is not uploading

<form class="pure-form pure-form-aligned" action="Processor.php" method="post" enctype="multipart/form-data" >
  <fieldset> 

  <div class="pure-control-group">
      <label for="image">Upload image</label>
      <input type="file" name="image" class="pure-input-1-4" />
    </div>
    <div class="pure-control-group">
      <label for="video">Upload video</label>
      <input type="file" name="video" class="pure-input-1-4"  />
    </div>

  </fieldset>
  <div class="pure-controls">
    <input type="submit" name="submit" value="Submit"  class="pure-button pure-button-primary" />
  </div>
</form>

php

$target1 = "../image/";  
$target2 =  time() . rand(11, 99). basename( $_FILES['image']['name']) ; 
$target3 = $target1 .  $target2;

$target4 = "../video/";  
$target5 =  time() . rand(11, 99). basename( $_FILES['video']['name']) ; 
$target6 = $target4 .  $target5;



if(move_uploaded_file($_FILES['image']['tmp_name'], $target3))  
{ 
    echo "The file &ldquo;". basename( $_FILES['image']['name']). "&rdquo; has been uploaded <br>"; 
} 
else 
{ 
    echo "Sorry, there was a problem uploading your file.\n <br>"; 
} 

if(move_uploaded_file($_FILES['video']['tmp_name'], $target6))  
{ 
    echo "The file &ldquo;". basename( $_FILES['video']['name']). "&rdquo; has been uploaded <br>"; 
} 
else 
{ 
    echo "Sorry, there was a problem uploading your file.\n <br>"; 
} 

Recommended Answers

All 16 Replies

By default the upload file size is 2mb. Is the video file larger? If yes, check your PHP.INI.

You need to set the value of upload_max_filesize and post_max_size in your php.ini :

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

After modifying php.ini file(s), you need to restart your HTTP server to use new configuration.

If you can't change your php.ini, you're out of luck. You cannot change these values at run-time; uploads of file larger than the value specified in php.ini will have failed by the time execution reaches your call to ini_set.

See the Manual Click Here

code is working for below 2mb files.
trying to reset php.ini

does following code will work? (not working for me yet)

<?php
    ini_set('upload_max_filesize', '200M'); 
?>

altered value for 'upload_max_filesize' to 200m in php.ini file. still not working for bigger than 6mb videos

try to find where your php.ini file is

most of the time im using xampp so the location of my php.ini is

xampp\php\php.ini

file is located in php folder

i think its on line 922

> code is working for below 2mb files.
> trying to reset php.ini
> does following code will work? (not working for me yet)
> <?php
>    ini_set('upload_max_filesize', '200M'); 
> ?>

does the video upload to the folder?

not working for "200MB" too

did you reset your xampp?

sorry my bad your code is correct

Did you read the link? You might need to set post limit and memory limit as well.

phpinfo(); have following values

upload_max_filesize 200MB 200MB
post_max_size 8M 8M
file_uploads On On

should I change value of post_max_size ??? if yes mention value?

your post_max_size can be the same as the upload_max_size

if you alter the php.ini you need to restart apache

restarted again & again
even restarted PC
But no result

Is it possible that it will work well with larger files on webserver from webhosting service?

yes but sometimes you will contact your hosting to active large file upload

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.