I just download dreamweaver extension for image upload. and run, It have some error... can anybody help... pls.. i have php 4.3.10. Notice: Undefined index: myimage in c:\program files\easyphp1-8\www\karsazest ate\upload.php on line 20 - <?php
-
// ---------------------------------------------
-
// Pure PHP Upload version 1.1
-
// -------------------------------------------
-
if (phpversion() > "4.0.6") {
-
$_POST = &$_FILES;
-
}
-
-
define("MAX_SIZE",300000);
-
define("DESTINATION_FOLDER", "./myimages/");
-
define("no_error", "success.php");
-
define("yes_error", "error.php");
-
$_accepted_extensions_ = "jpg,jpeg,png,gif,bmp";
-
if(strlen($_accepted_extensions_) > 0){
-
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
-
} else {
-
$_accepted_extensions_ = array();
-
}
-
-
$myfile = $HTTP_POST_FILES['myimage'];
-
-
if(is_uploaded_file($myfile['tmp_name']) && $HTTP_POST_FILES['myimage']['error'] == 0){
-
$errStr = "";
-
$_name_ = $myfile['name'];
-
$_type_ = $myfile['type'];
-
$_tmp_name_ = $myfile['tmp_name'];
-
$_size_ = $myfile['size'];
-
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
-
$errStr = "File troppo pesante";
-
}
-
$_ext_ = explode(".", $_name_);
-
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
-
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
-
$errStr = "Estensione non valida";
-
}
-
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
-
$errStr = "Cartella di destinazione non valida";
-
}
-
if(empty($errStr)){
-
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
-
header("Location: " . no_error);
-
} else {
-
header("Location: " . yes_error);
-
}
-
} else {
-
header("Location: " . yes_error);
-
}
-
}
-
?>
-
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
-
<table width="354" border="10" cellspacing="10" cellpadding="0">
-
<tr>
-
<td width="102">image</td>
-
<td width="252"><input type="file" name="myimage" /></td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td><input type="submit" name="Submit" value="Submit" /></td>
-
</tr>
-
</table>
-
</form>
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator 3 3359 Markus 6,050
Recognized Expert Expert
[php]
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$_POST = &$_FILES;
}
define("MAX_SIZ E",300000);
define("DESTINA TION_FOLDER", "./myimages/");
define("no_erro r", "success.ph p");
define("yes_err or", "error.php" );
$_accepted_exte nsions_ = "jpg,jpeg,png,g if,bmp";
if(strlen($_acc epted_extension s_) > 0){
$_accepted_exte nsions_ = @explode(",",$_ accepted_extens ions_);
} else {
$_accepted_exte nsions_ = array();
}
$myfile = $HTTP_POST_FILE S['myimage'];
if(is_uploaded_ file($myfile['tmp_name']) && $HTTP_POST_FILE S['myimage']['error'] == 0){
$errStr = "";
$_name_ = $myfile['name'];
$_type_ = $myfile['type'];
$_tmp_name_ = $myfile['tmp_name'];
$_size_ = $myfile['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ex t_[count($_ext_)-1]);
if(!in_array($_ ext_, $_accepted_exte nsions_) && count($_accepte d_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DEST INATION_FOLDER) && is_writeable(DE STINATION_FOLDE R)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errSt r)){
if(@copy($_tmp_ name_,DESTINATI ON_FOLDER . "/" . $_name_)){
header("Locatio n: " . no_error);
} else {
header("Locatio n: " . yes_error);
}
} else {
header("Locatio n: " . yes_error);
}
}
?>
<form action="" method="post" enctype="multip art/form-data" name="form1" id="form1">
<table width="354" border="10" cellspacing="10 " cellpadding="0" >
<tr>
<td width="102">ima ge</td>
<td width="252"><in put type="file" name="myimage" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
[/php]
It makes it so much easier for people to read. (please read forum guidelines)
Markus 6,050
Recognized Expert Expert
When you get "undefined index" it means that you have referred to an indeces in an array which doesnt exist. i.e. 'myimage' in http_post_files () doesnt exist.
In my oppinion, that code is awful and old. old. old. old.
check out this tutorial. It's much neater and well up-to-date :)
Of course the myimage key does not exist because you haven't submitted the upload form when you first enter the script.
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Coder Droid |
last post by:
I decided to run some code with errors set to E_ALL, just to see what I
would run across. It caught a few things, but 90% or better of the
messages were of the 'undefined' kind:
PHP Notice: Undefined variable
PHP Notice: Undefined index
PHP Notice: Undefined property
I'd like to go back and fix what I can, but I'm wondering: how good or
bad is this? I mean, I rely on the fact that the first use of a variable
|
by: petermichaux |
last post by:
Hi,
I am curious about how php deals with the following situation where I
use an undefined index into an array. PHP seems to be behaving exactly
how I want it to but I want to make sure that it is not a fluke. It
seems like most programming languages would crash if you used an
undefined index. Why does PHP work the way it does?
My example is below
|
by: John Oliver |
last post by:
PHP Notice: Undefined index: name in
/home/www/reformcagunlaws.com/new.php on line 6
PHP Notice: Undefined index: address in
/home/www/reformcagunlaws.com/new.php on line 7
PHP Notice: Undefined index: city in
/home/www/reformcagunlaws.com/new.php on line 8
PHP Notice: Undefined index: county in
/home/www/reformcagunlaws.com/new.php on line 9
PHP Notice: Undefined index: zip in
/home/www/reformcagunlaws.com/new.php on line...
|
by: Alan Schroeder |
last post by:
The following code produces the expected results on a PC using gcc, but I
need to port it (or least something similar) to a different
platform/compiler. I don't think I've introduced any undefined behavior but
would like another set of eyes to check.
#include <math.h>
#include <stdlib.h>
extern float window;
|
by: deepak |
last post by:
Using 'char' as an array index is an undefined behavior?
| |
by: cassbiz |
last post by:
Here are the errors that are coming up in my error_log
Notice: Undefined index: andatum in /zipcode.php on line 11
Notice: Undefined index: andatum in /zipcode.php on line 12
Notice: Undefined index: abdatum in /zipcode.php on line 13
Notice: Undefined index: zimmer in /zipcode.php on line 14
Notice: Undefined index: city in /zipcode.php on line 39
Notice: Undefined index: state in /zipcode.php on line 41
|
by: number1yan |
last post by:
Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:
Notice: Undefined index: FriendName in D:\Yan\Over_8\SendEmail.php on line 4, Notice: Undefined index: FriendEmail in D:\Yan\Over_8\SendEmail.php on line 5, Notice: Undefined index: Name in D:\Yan\Over_8\SendEmail.php on line 6, Notice: Undefined index: Email...
|
by: bill |
last post by:
I am trying to write clean code but keep having trouble deciding
when to quote an array index and when not to.
sometimes when I quote an array index inside of double quotes I
get an error about enased whitespace (to my best memory)
AT other times I get an undefined index notice as below:
Notice: Undefined index: last_reminder_id in...
|
by: siyaverma |
last post by:
Hi,
I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that,
After doing some changes when i run it on my local server it was working fine but giving some errors those are
Notice: Undefined index: phplogin in C:\Inetpub\wwwroot\sampleft\index.php on line 116
Notice: Undefined variable: username in C:\Inetpub\wwwroot\sampleft\index.php on line 116
...
|
by: sickboy |
last post by:
$channels=$_GET; if (empty($channels)) { $channels='blank'; } changechannels($channels);
$theatre=$_GET; if (empty($theatre)) { $theatre='splash'; } changetheatre($theatre);
$info=$_GET; if (empty($info)) { $info='noinfo'; } changeinfo($info);
Hey everyone,
I keep getting an error regarding the above code. These are the errors:
Notice: Undefined index: channels in /home/forcefed/public_html/index.php on line 5
|
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: 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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |