473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to get value of file type input in php

Expand|Select|Wrap|Line Numbers
  1. <?php ?>
  2. <html>
  3.     <head>
  4.        <script language="javascript">
  5.             function getpath()
  6.     {
  7.     var pname = document.form1.fr.value;
  8.     return pname;
  9.     }
  10.        </script>
  11.      </head>
  12.      <body>
  13.             <form enctype="multipart/form-data" name="form1" action="fileread.php" method="POST">
  14.                      <input type="file" name="fr" id="fr"> <br><br>
  15.          <input type="submit" name="submit" value="Read" >
  16.              </form>
  17.  
  18.         <?php
  19.                 if(isset($_POST['submit']))
  20.           {
  21.                   //$myfile="E:\sachins\projects\me\myfile.txt"; -This is static path
  22.                       $myfile= $_FILE["fr"];   //i want value of fr which is input file type
  23.                 echo $myfile;
  24.           $fr=fopen($myfile,"r");
  25.                       while (!feof($fr))
  26.         {                
  27.         echo  fgets($fr). "<br />";
  28.         }
  29.           ?>
  30.      </body>
  31. </html>
  32.  
i am trying with above code to get the value input in file type in php code
and not able to get this thing.
i know how to take path in javascript
but don't know how to pass that value to php code
Please help me...
May 22 '07 #1
1 18457
Atli
5,058 Expert 4TB
Hi, and welcome to TSDN.

I am not entirly sure what you are trying to do. Please try to explain this a bit better so we can try to assist you.

I am, however, going to take an educated guess, and say that you are trying to get some information about some file?

If so you could try something like this:
Expand|Select|Wrap|Line Numbers
  1. <?php ?>
  2. <form enctype="multipart/form-data"  action="?" method="POST">
  3.   <input type="file" name="fr" id="fr"> <br><br>
  4.   <input type="submit" name="submit" value="Read" >
  5. </form>
  6.  
  7. <?php
  8.   if(isset($_POST['submit']))
  9.   {
  10.     echo "<pre>";
  11.     print_r($_FILES);
  12.     echo "</pre>";
  13.   }
  14. ?>
  15.  
May 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
2
by: IkBenHet | last post by:
Hello, I am uploading a file using this form in ASP.NET. I have also added a simpel textfield: <form runat="server" enctype="multipart/form-data"> <input type="file" id="oFile" Name="oFile"...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
12
by: Doogie | last post by:
How do I make a value the default value for a combo box in ASP 3.0? What I have below does NOT work, yet I've seen it in HTML file examples before (and works if I put it in a HTML file by itself,...
1
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
5
by: montybytes | last post by:
Hi there, Although, I have already placed this question in the HTML/CSS section, perhaps it might be worthwhile asking the question here as well. I have a JavaScript function which retrieves...
9
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why...
4
SuperMetroid
by: SuperMetroid | last post by:
The html code of the form, and my code are below. I can't get the value to post/submit.. instead I get an error. Can anyone help? HTML Code of Form: <form method='post' autocomplete='off'> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.