This is my form.php

      <form name="form" action="upload.php" method="post" enctype="multipart/form-data">
                <?php $id=$_REQUEST['id1']; ?>
        <label>Category: </label><?php echo
        '<input type="text" name="category" onfocus="blur()" value='.$id.'>'?></br>
            <label>Name:</label>
            <input type="text" name="name" size="32"></br></br>
            <label>Type:</label>
            <select name="type">
                <option value="Audio">Audio</option>
                <option value="Video">Video</option>
                <option value="Read">Read</option>
                <option value="Quiz">Quiz</option>
            </select>
            <label>Description:</label></br>
            <textarea rows="10" cols="30" name="description"></textarea></br>                  </br>
            <label>File:</label>
            <input type="file" name="files"/></br>
            <input type="submit" value="upload" name="up">
        </form>

and my upload.php

        include("connect.php");


        if(isset($_REQUEST['up']))
        {
        $nagan=$_FILES['files']['name'];    
        $tmp_loc=$_FILES['files']['tmp_name'];

         echo $nagan;
         echo $tmp_loc;
            $bookCover="modules/".$nagan;

            move_uploaded_file($tmp_loc,$bookCover);

            $sql="INSERT INTO modules (name, type, description, filename, category)VALUES('$_POST[name]','$_POST[type]','$_POST[description]','$bookCover','$_POST[category]')";

           mysql_query($sql);

    $count=mysql_affected_rows();

    if($count==1)
    {

      echo "File $nagan Successfully Uploaded!";

    }else
      echo "Error!";


      }

    ?>

Uploading images and pdf files work fine but when i try to upload audio files it does not show in the designated folder (modules folder) but it saves a value in the database. Also, when i try to upload a video file the upload.php does not work at all. Please help me. I am trying to figure this out for two days now. help.

有帮助吗?

解决方案

What is the value of upload_max_filesize and post_max_size in your php.ini? And what is the size of the audio files you tried to upload?

  print ini_get('upload_max_filesize').' MBytes (Upload max size) <br/>'.
        ini_get('post_max_size').' MBytes (Post Max Size)'; 

these two shows you the result in MBbytes. If this is too small,

1) Try: ini_set('upload_max_filesize','the size you need');
        ini_set('post_max_size','the size you need');
2) If the 1) does not works : 
  try to set the value of this properties in your php.ini  
      (on linux use this command to find: locate php.ini, or find / -name php.ini)
      (on windows use the file search tool)
  restart apache /if you use apache/ or the webserver deamon what you use
3) If you could not do 1) or 2)  (because do not have access this property) contact to the server administrator.

And before these all try to upload small (smaller than 1MB) audio and video files.

其他提示

The following options are relevant:

PHP: upload_max_filesize (in php.ini or .htaccess only, won't work using ini_set())

PHP: post_max_size

PHP: max_input_time

and possibly

Apache: LimitRequestBody

There may be permission problem in php.ini for max upload size.

upload_max_filesize = 10M

; Must be greater than or equal to upload_max_filesize

post_max_size = 10M

You can change it too, and restart the server.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top