Jump to content

New Post : Problem with file upload


inspire

Recommended Posts

 

I have problem upload file. i am using php4.0.5. this upload file code work file in my friend pc which run php5.but in my pc, the page2.php display with empty page and the file not inserted into database.

 

is that any setting need to be done in my php4.0.5 conf file? Pls help :-[

 

 

page1.php

 

<html>

<head>

 

</head>

 

<body bgcolor='#87CEFA'>

 

 

 

 

<table>

<tr>

<td height="54"><b><font color="3300FF">Add Slide :</font></b>

  <input name="new_file" type="file" size="25" >

        <input type="Submit" value=" Upload" name="Submit">

      <input type="hidden" name=MAX_FILE_SIZE; value="9000000">

      <input type="hidden" name="ref" value="<? echo $id; ?>" ></td>

</tr>

</table>

 

</form>

</body>

</html>

 

page2.php

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

 

<body>

 

<?php

 

$idt = $HTTP_POST_VARS['ref'];

 

  mysql_connect("localhost","trainee","123") or die ("Unable to connect server");

  mysql_select_db("gddatab") or die("Unable connect database");

 

 

  if(isset($_POST['Submit'])&& $_FILES['new_file']['size'] > 0)

  {

      $fileName = $_FILES['new_file']['name'];

      $tmpName  = $_FILES['new_file']['tmp_name'];

      $fileSize =$_FILES['new_file']['size'];

      $fileType =$_FILES['new_file']['type'];

 

      $fileopen=fopen($tmpName,'r');

      $content=fread($fileopen,fileSize($tmpName));

      $content=addslashes($content);

      fclose($fileopen);

     

      if(!get_magic_quotes_gpc())

      {

 

      $fileName=addslashes($fileName);

 

      }

 

 

      $sql="insert into ots_slide values ('','$fileName','$fileType','$fileSize','$content','$idt','jeeva','".date('y-m-d')."') ";

      $result=mysql_query($sql) or die ("Action Insert Fail");

     

 

 

        echo "<script languange = 'Javascript'>

alert('File $fileName uploaded');

location.href = 'page1.php';

</SCRIPT>";

 

}

 

?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/70611-new-post-problem-with-file-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.