I am working on a site currently. And I did make it live but I had to put it off due to this problem I found. I saw other threads with kind of same problem as well but nothing seems to solve mine.
Here the php code I am using to upload files.
Expand|Select|Wrap|Line Numbers
- </TR>
- <tr>
- <td><h3>File: </h3></td>
- <td width="200">
- <input type="hidden" name="MAX_FILE_SIZE" value="20000000">
- <input name="userfile" type="file" id="userfile">
- </td>
- <td width="50"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
- </tr>
- </table>
- </form>
- <?php
- if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
- {
- $description = $_REQUEST['description'];
- $cat = $_POST['Category'];
- $fileName = $_FILES['userfile']['name'];
- $tmpName = $_FILES['userfile']['tmp_name'];
- $fileSize = $_FILES['userfile']['size'];
- $fileType = $_FILES['userfile']['type'];
- $fp = fopen($tmpName, 'r');
- $content = fread($fp, filesize($tmpName));
- $content = addslashes($content);
- fclose($fp);
- if(!get_magic_quotes_gpc())
- {
- $fileName = addslashes($fileName);
- }
- $query = "INSERT INTO upload (name, size, type, content, description, username, category) ".
- "VALUES ('$fileName', '$fileSize', '$fileType', '$content', '$description', '$name', '$cat')";
- mysql_query($query) or die('Error, query failed');
- echo "<br>Hurray!!!File $fileName has been successfully uploaded..Upload another file or go back to home<br>";
I checked the php.ini settings and the values are-
max_execution_time 300 --> in case it take too long to upload
post_max_size = 128 M
upload_max_filesize = 28 M
memory_limit = 128M
What could be wrong?
TIA
Chirag Narula