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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.