473,396 Members | 1,703 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,396 software developers and data experts.

Create browse box

48
Dear friends,

I need to create a browse box for my final part of assignment. Can anyone tell me how to create a browse box?

Appreciate for any reply. Thank you.

Best Regards.
Mar 4 '07 #1
11 1570
mainul
51
[HTML]
<html>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="">
Browse your file
<input name="file_read" type="file" id="file_read">
<input type="submit" name="Submit" value="OK">

</form>
</body>
</html>
[/HTML]

is this the code what you are looking for ?

Best regards
Mainul
Mar 4 '07 #2
kuzure
48
Dear Mainul,

Hrm, I had try to change the <html> to <?php because I need a .php, but of course, it didnt work.

By the way, I also modifying the code cuz after I click the "OK" button, I need to store text into a text file. For instance, testing.txt.

Thanks for the reply.

Best Regards.
Mar 4 '07 #3
mainul
51
Dear Mainul,

Hrm, I had try to change the <html> to <?php because I need a .php, but of course, it didnt work.

By the way, I also modifying the code cuz after I click the "OK" button, I need to store text into a text file. For instance, testing.txt.

Thanks for the reply.

Best Regards.
well next time you should post your msg more details. now tell me what exactly you want and what code did u develop so far.

best regards
Mainul
Mar 5 '07 #4
kuzure
48
well next time you should post your msg more details. now tell me what exactly you want and what code did u develop so far.

best regards
Mainul

Sorry for the inconvenient. haha^^

Ok. Actually I need a web page with browse box and a "ok" button only. Then, when I click the "ok" button, the text of the browse box will store in "testing.txt".

I had used xampp to host a server. I can use localhost to load the web page and store a "1" to testing.txt. Here is my code.

[HTML]<?php
$filename = 'testing.txt';
$somecontent = "this data will store in text file";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

} else {
echo "The file $filename is not writable";
}


?>[/HTML]

The testing.txt need to create manually. or else, it will appear error.

Best Regards.
Mar 5 '07 #5
kuzure
48
Dear Mainul,

sorry, something forgot to tell you. The code above is only can load and it will store the text in "$somecontent". If you use dreamreaver to open it, it is totally blank.

Well, since I know how to store data to a file, I thought I can use the same theory to modify your code. But I'm wrong, I totally dunno how to link or command the button to do anything. haha^^

So, the conclusion is, I need a browse box and an "ok" button. When I click on the "ok" button, the text that appear in the browse box will store in a file named "testing.txt".

Best Regards.
Mar 5 '07 #6
mainul
51
Dear Mainul,

sorry, something forgot to tell you. The code above is only can load and it will store the text in "$somecontent". If you use dreamreaver to open it, it is totally blank.

Well, since I know how to store data to a file, I thought I can use the same theory to modify your code. But I'm wrong, I totally dunno how to link or command the button to do anything. haha^^

So, the conclusion is, I need a browse box and an "ok" button. When I click on the "ok" button, the text that appear in the browse box will store in a file named "testing.txt".

Best Regards.
is it texbox or text area? i think there is nothing called browse box
Mar 5 '07 #7
sir

how to send notifications when our data matches
Mar 5 '07 #8
mainul
51
Try out this code. Hope you wil find your solutions.
save it as input.html

[HTML]
<form name="form1" method="post" action="write.php">
Enter your Name:
<input name="Name" type="text" id="Name" value="">
<br>
Email:
<input name="Email" type="text" id="Email" value="">
<br>
<input name="Phone" type="text" id="Phone" value="">
<br>
Phone:
<input type="submit" name="Submit" value="Submit">
<br>
</form>
[/HTML]

write.php
[PHP]
<?
// Define file to save to:
$fileLocation = 'file.txt';
$lastElement = array_pop($_POST);

// Implode the $_POST array,
// Save each value in format "Value0 || Value1 || Value2" etc:
$savePost = implode(' || ', $_POST);

// Open file (defined above),
// Set action to 'a' for 'append' - won't overwrite existing file contents:
$fp = fopen($fileLocation,'a') or die('Could not open file.');

// Lock file temporarily so nobody can access it while it's being written to:
flock($fp,LOCK_EX);

// Write $savePost to a new line in the file:
fwrite($fp,$savePost."\n");

// Unlock the file so it can be used again:
flock($fp,LOCK_UN);

// Close file:
fclose($fp);

?>
[/PHP]

read.php

[PHP]
<?

// Define file to read:
$fileLocation = 'file.txt';

// Read the file into an array by line:
$fileContents = file($fileLocation);

//Start table:
echo '<table><tr>';
echo '<td>NAME</td>';
echo '<td>EMAIL</td>';
echo '<td>PHONE</td>';
echo '</tr>';

// Loop thru the file by line:
foreach($fileContents as $line) {
// Trim newline \n and other whitespace:
$line = rtrim($line);
// Explode Values into an array:
$values = explode(' || ', $line);
// Print the results:
echo '<tr>';
for($n=0; $n<count($values); $n++) echo '<td>'.$values[$n].'</td>';
echo '</tr>';
}

// End table:
echo '</table>';

?>

[/PHP]
Mar 5 '07 #9
kuzure
48
Dear Mainul,

Hrm, the code is ok until i test something. Remember I told you I wanted to build a "browse box"? it is called a "File Field" in dreamreaver. I need to get the file address and store in a text file.
For instance, C:\Documents and Settings\Yahoo\YourFile.txt

But, when it comes to store this address, it appear this in the text file, C:\\Documents and Settings\\Yahoo\\YourFile.txt

Notice there are double back slash at the address. what happen?

The result quite funny. But it is ok for normal data such like name, email, and phone number. haha^^

Best Regards.
Mar 5 '07 #10
ronverdonk
4,258 Expert 4TB
It is using the escape character (\) to escape funny characters, such as backslashes, single and double quotes and NULL. It is added before those characters.

Ronald :cool:
Mar 5 '07 #11
kuzure
48
It is using the escape character (\) to escape funny characters, such as backslashes, single and double quotes and NULL. It is added before those characters.

Ronald :cool:

Erm, sorry, I dont get it. How to solve this problem anyway?

Actually this part has connection with another. This is the final part of my assignment, haha^^. I had posted a question that ask for help in php link with VB. But since there is no one answer my question, I decide to change a method to do my project.

The problem is, I will use VB to load the file that store the data that get from web page. But, if there are double slashes occur, VB will pop out an error because it doesnt understand it.

Hope you can give me some clue.

Best Regards.
Mar 7 '07 #12

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

Similar topics

5
by: Jon D | last post by:
I have a form where a user enters their name, date etc. i also want them to be able to click on a browse button and select a file which will then appear in a textbox. when they press submit i want...
2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
0
by: Jahyen | last post by:
I'm trying to create a new web project using File...New...Project. The web server is on the internet and has FP2002 extensions installed. I can connect to the server using FP2002. If I try to...
9
by: Marc Miller | last post by:
Hi all, I have 2 dev. machines, the 1st is Win 2000 with .NET 7.0 and the 2nd is XP Pro with .NET 2003. My Web Server is Win 2000 Server with IIS 5.0. I can create a new project on my test...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
3
by: Highlander | last post by:
Hello all. Consider the following HTA: <HTML> <HEAD> <TITLE></TITLE></HEAD> <BODY> <SCRIPT LANGUAGE="VBScript"> Sub ButBrowse_onclick() '-- show browse window and Get file path:
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
4
by: Keith G Hicks | last post by:
I'm an experienced foxpro, vba, delphi, sql programmer but this is something new to me. I'm creating a pretty simple vb.net exe (scantextfiles.exe) that will run on a server and read some text...
0
by: Rajakumarrs | last post by:
i wish to create a form with browserdialog,button ...i add a browse button from activex control...but i want to take browse path from that browse button control,i cant ..plz help me.. in screen shot...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.