Hi all!
I'm newbie on php. On the web site i'm developing, i have encoutered a problem that i can't resolve.
I have a script that makes the file upload, and then, based on the upload, it displays a message on another .php file. (success, or invalid file). When a user uploads a file, and a "success" message is displayed, when the same user uploads another file and it is displayd a error message, this error message appears under the previous "echo" success message...
I want that when a user makes a success upload, if the next upload displays an error message, that message appears in the same page as the previous one, but without the previous "success" message that appeared.
Here is my upload.php and success.php scripts:
########upload. php############ ##
session_start() ;
$temp_upload="t emp_upload/";
/*$server="local host";
$user="root";
$password="";
$db="teste";
$con=mysql_conn ect($server, $user, $password);
if(!$con)
{
die('Could not connect:'.mysql _error());
}
else{
$descricao=$_PO ST["descriptio n"];
$query="INSERT INTO files(descripti on) VALUES('$descri ption')";
mysql_query($qu ery);
mysql_close();
*/
$filename=$HTTP _POST_FILES['userfile']['name'];
$filetype=$HTTP _POST_FILES['userfile']['type'];
$filesize=$HTTP _POST_FILES['userfile']['size'];
if ( ($filetype=="ap plication/msword") || ($filetype=="te xt/plain") || ($filetype=="ap plication/pdf") && ($filesize<1000 000)) {
if ( (move_uploaded_ file($HTTP_POST _FILES['userfile']['tmp_name'], "temp_uploa d/".$HTTP_POST_FI LES['userfile']['name']))){
$_SESSION["upload"]=1;
header("Locatio n:success.php") ;
}
else{
$_SESSION["upload"]=2;
header("Locatio n:success.php") ;
}
}
else{
$_SESSION["upload"]=3;
header("Locatio n:success.php") ;
}
?>
############### #######
#######success. php############ ###
<?php
session_start() ;
echo"Sessão Iniciada como: ".$_SESSION["login"];
?>
<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p></p>
<p></p>
<p></p>
<label><b>FIL E UPLOAD</b></label>
<p></p>
<table>
<form id="form" name="form" method="post" action="upload. php" enctype="multip art/form-data">
<tr>
<td><label for="descriptio n">document description</label></td>
<td><input name="descripti on" type="text" id="description "/></td>
</tr>
<tr><td><labe l for="file">Choo se File</label><td><inpu t name="userfile" type="file"></td>
<tr><td></td>
<td><input type="submit" value="Enviar">
</td>
</tr>
</form>
</table>
<label><?php if(($_SESSION["upload_success "]=1))
echo"<b>File was succefully uploaded</b>";
if(($_SESSION["upload_success "]=2))
echo"<b>Error while uploading the file</b>";
if(($_SESSION["upload_success "]=3))
echo"<b>Invalid File</b>";
?>
</label>
</body>
</html>
############### #######
0 1331 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Newgene |
last post by:
Hi, group,
May I ask a newbie question?
Given the below example:
for i in range(100):
print "%s%%" % i
I want to show the progress by print 1% to 100%. But I hope each
output will clear the previous output before print, so that I can see a
|
by: KC |
last post by:
Hello
I installed MySQL ver 4.0.20d on a Windows XP Professional PC. I created a
user and database that I would like to delete, and at this point I would
just like to uninstall MySQL and do a fresh installation.
I have deleted MySQL by going to Start > Settings > Control Panel > Add or
Remove Programs. However, when I reinstall MySQL, the previous user and
database are restored, too. How does one do a complete removal of MySQL so...
|
by: Steve S |
last post by:
I need some help modifying this code. The code was orginally setup to
add/remove a single table row. I modified it to add 2 (two) rows with
one column that spans both rows. That part works. I just need help
with the removerow function. Thanks for any help you can offer me.
Here is the code:
<html>
<head>
<title>New Document</title>
<script type="text/javascript">
|
by: koperenkogel |
last post by:
Dear cpp-ians,
I am writing code for a image segmentation program. For this purpose I
want to make a list (or array) of all pixels and take a random pixel
out of the list. Once the pixel is handled, I want to remove it from
the list and take again a random pixel out of the new list (with the
previous pixel removed).
I have an image of 1450 x 1650 pixels. Every pixel is a pointer to a
structure:
|
by: Johm |
last post by:
I need some help in finding a way to remove the filter from the
previous command.
I open the report from a form where i have option group called
Office.Depending on the option
in the option group,the record source in the report is filtered for
this option.
In the OnOpen event of the report i have :
Public town As Long
town = Forms!!
| |
by: Markus |
last post by:
Hi!
I wanted to select a subset of nodes (list =
selectNodes("parent/child") from a XmlDocument, then remove all
(parentNode.removeAll();) child-nodes and insert the previous selected nodes
back. Of course the XmlNodes in the nodelist ref. where lost once the
removeAll() were executed, this is expected.
So the obvious way to achive the result would be to clone the nodes or
remove the nodes not qualifying the Xpath.
|
by: eksamor |
last post by:
I have a simple linked list:
struct element {
struct element *next;
int start;
};
struct list {
struct element *head;
|
by: Hermann.Richter |
last post by:
Is there any way to remove automatically all blank chars from the html
sent to the client??
Example:
----------------------------------------------------------------
<?
echo "HTML tags here<br>" ;
?>
more HTML here
<div>
|
by: bahoo |
last post by:
Hi,
I have a list like
and as output I want
If I
myList.remove('0024')
then only the first instance of '0024' is removed.
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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.
| |