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
Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator
Code:
<?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>
Comment