httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "kartikay malhotra" <>
Subject [users@httpd] Upload files to local directory
Date Wed, 17 May 2006 14:05:15 GMT
Hi everyone!

I'm a linux user. I want to upload files to my Apache HTTP server. I have a
MySQL database in place. But prior to that I wish to save uploaded files in
a temporary folder.

I've used PHP scripts with HTTP POST method. But to no avail. No matter what
tutorial I consult, I cannot save the uploaded file.

1. What could I be doing wrong?

My file for reference:

<title>Upload File To MySQL Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">


        $fileName = $_FILES['userfile']['name'];
        $tmpName  = $_FILES['userfile']['tmp_name'];
        $fileSize = $_FILES['userfile']['size'];
        $fileType = $_FILES['userfile']['type'];

        echo $fileName;
        echo "<br>";
        echo $tmpName;
        echo "<br>";
        echo $fileSize;
        echo "<br>";

        $target_path = "/var/www/html/";

        $target_path = $target_path . basename(

         if(move_uploaded_file($tmpName, $target_path)) {
            echo "The file ". basename( $fileName). " has been uploaded";
             echo "There was an error uploading the file, please try

<form action="" method="post" enctype="multipart/form-data"
  <table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
      <td width="246"><input type="hidden" name="65536"
value="2000000"><input name="userfile" type="file" class="box"
      <td width="80"><input name="upload" type="submit" class="box"
id="upload" value="  Upload  "></td>

Sample output:
There was an error uploading the file, please try again!

Please help!!
Many Thanks

View raw message