I am trying to make a site available for someone to *upload* certain type of text file (.txt) that can be parsed by written code. the upload file is available on the main site but I need this to result in different page on the right as someone clicks on SUBMIT with one's file attached. The uploaded file by clicking submit button should be PARSED on the right side of the page but when I click on the submit with the file now, it goes to the local host main page. I don't know what I have to do. This is what I currently have on the website, below picture! ![](/images/imgserve.php?url=http://personal.psu.edu/kvl5046/question.png) the code is what I currently have for the THEME folder for Drupal page. Line 39-45 is what I wrote for the uploading file part. - <?php
-
// $Id: page.tpl.php,v 1.28.2.1 2009/04/30 00:13:31 goba Exp $
-
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language ?>" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
-
-
<head>
-
<?php print $head ?>
-
<title><?php print $head_title ?></title>
-
<?php print $styles ?>
-
<?php print $scripts ?>
-
<script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
-
</head>
-
-
<body>
-
-
<table border="0" cellpadding="0" cellspacing="0" id="header">
-
<tr>
-
<td id="logo">
-
<?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
-
<?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
-
<?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
-
</td>
-
<td id="menu">
-
<?php if (isset($secondary_links)) { ?><?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?><?php } ?>
-
<?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?><?php } ?>
-
<?php print $search_box ?>
-
</td>
-
</tr>
-
<tr>
-
<td colspan="2"><div><?php print $header ?></div></td>
-
</tr>
-
</table>
-
-
<table border="0" cellpadding="0" cellspacing="0" id="content">
-
<tr>
-
<?php if ($left) { ?><td id="sidebar-left">
-
<?php print $left ?>
-
-
<form action="test_0512.php" method="post"
-
enctype="multipart/form-data">
-
<label for="file">Upload the file: </label>
-
<input type="file" name="file" id="file" />
-
<br />
-
<input type="submit" name="submit" value="Submit" />
-
</form>
-
-
-
</td><?php } ?>
-
<td valign="top">
-
<?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
-
<div id="main">
-
<?php print $breadcrumb ?>
-
<h1 class="title"><?php print $title ?></h1>
-
<div class="tabs"><?php print $tabs ?></div>
-
<?php if ($show_messages) { print $messages; } ?>
-
<?php print $help ?>
-
<?php print $content; ?>
-
<?php print $feed_icons; ?>
-
</div>
-
</td>
-
<?php if ($right) { ?><td id="sidebar-right">
-
<?php print $right ?>
-
</td><?php } ?>
-
</tr>
-
</table>
-
-
<div id="footer">
-
<?php print $footer_message ?>
-
<?php print $footer ?>
-
</div>
-
<?php print $closure ?>
-
</body>
-
</html>
-
I have test_0512.php as a page that website should be resulted as clicking on Submit button.. but i don't know it seems like its not working. I don't know how to do this..Please help me out :( -
<html>
-
-
<head>
-
-
<title>TESTING PAGE</title>
-
</head>
-
<body>
-
<?php
-
-
-
$file = $_FILES['fileHandle']['name'];
-
-
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
-
"C:/upload/" . $_FILES["fileToUpload"]["name"]);
-
-
if ($_FILES["fileToUpload"]["error"] > 0)
-
{
-
echo "Apologies, an error has occurred.";
-
echo "Error Code: " . $_FILES["fileToUpload"]["error"];
-
}
-
else
-
{
-
-
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
-
"C:/upload/" . $_FILES["fileToUpload"]["name"]);
-
}
-
-
-
//$file = fopen($fileName, "r") or exit ("Unable to open file!");
-
-
while(!feof($file))
-
{
-
-
$line = fgets($file); // Read a line.
-
-
-
//escape if the line is empty
-
if (trim($line) == "")
-
continue;
-
//explode from the :
-
$fields = explode(":", $line, 2);
-
-
echo "<b>$fields[0]</b>";
-
-
//checks if second part exists
-
if (isset($fields[1]))
-
echo " : $fields[1]";
-
-
echo "<br/>";
-
-
}
-
-
fclose($file);
-
?>
-
-
</body>
-
</html>
-
-
-
Someone replied me that I should put below code but I could not get it.. -
if(isset($_POST['submit'])) {
-
//add your file processing code here
-
-
-
}else{
-
// add your upload form here
-
-
-
}
-
2 9436 dlite922 1,584
Recognized Expert Top Contributor
I'm not familiar with Drupal, but the code suggested means that if anything is submitted (in $_POST['submit']), then do this, else display the original page (whatever the page is before the user clicks submit)
I'm worried that if you don't understand that piece of code, how you will have the level of PHP programming skills to do what you need to do.
I would go back to some PHP tutorials and learn the language more if you want to do this yourself
Good luck,
Dan
@dlite922
actually I understood that part I just did not know how to implement that...
I meant, I plugged this recommended code into the page where the replier mentioned me to do but that was messing me up with other codes..
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: anonieko |
last post by:
Scenario: You have a page that is TOO slow to refresh.
But it allows partial flushing of html contents. I.e.
Submit button already appears but you don't
want your users to click on it prematurely
because other parts are still coming.
Here I put a javascript the will enable only
submit button only after 5 seconds after the page
is load fully.
|
by: Brian |
last post by:
Hi, I've been trying to find a way to upload file to another site that
is not using IIS. The site that I want to upload file to has a simple
php script to receive file uploaded through standard http post with a
file upload. However, how do I upload file to the site using asp.net?
thanks
Brian
|
by: Brian |
last post by:
Hi, I've been trying to find a way to upload file to another site that
is not using IIS. The site that I want to upload file to has a simple
php script to receive file uploaded through standard http post with a
file upload. However, how do I upload file to the site using asp.net?
thanks
Brian
|
by: Ibrahim. |
last post by:
Hi,
I have a login page, the problem I'm facing is like this;
1. Login page with submit button (being default button);
2. When first time the page is submitted then submit code is called.
3. Again when page refresh is done by (f5) then submit button is fired
implicitly.
|
by: todanrg3 |
last post by:
It is possible to upload files to Rapidshare from another page?(not using Rapidshare's own form). How can i do this with PHP?
| |
by: ChrisN |
last post by:
Invoking a postback before a large ASP.NET page has fully rendered
will often cause the page to crash. This is unhelpful and confusing
to users.
I'm wondering if I can overcome this by disabling any controls that
invoke a postback until the page is fully rendered, ie setting the
controls disabled server-side, serving the page and then having a
JavaScript routine right at the bottom of the page re-enable them
client-side.
|
by: pratibharaut |
last post by:
i'm not able to upload file from mobile J2ME to php 5.2.2, plz help me for that,
same code is running in php4.3, but not in php5.2.2.
I'm using $_FILES for uploading file, while using
print_r($_FILES), it showname,type and
error=3 and size=0
why this is happened?
plz help me .
|
by: Bjorn Sagbakken |
last post by:
I was looking for a solution, without the full page postback, and all the
tip was about a hidden iframe and RJS.
The RJS was not known to me before, and still I haven't explored this used
with ASP.NET
But, the iframe issue gave me an idea; why not put the fileupload control &
a submit button on a form, nothing else. Then on my main form I added an
iframe, a visible one, with src=the form with the file upload control.
Ok, this shows...
|
by: obj63 |
last post by:
Hello All,
I am posting to a page with out a submit button using the function sendToHost - http://dodds.net/~cardinal/sendtohost.txt
I send the following
sendToHost('www.example.com','post','/page.php', 'ERROR=01');
where www.example.com is my site.
The problem then is that page.php on the site should then read from the $_POST variable and write out the Error to the file.
|
by: ChristinaTIT |
last post by:
Hi,
I have a form containing
ID
Type
Quantity
Rate
values. it should have two submit buttons which, when posted, will do the two different things in two different scripts.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |