Forum Moderators: coopster
here's the script
<?
$image_folder = "/Image/";
$do = isset($_REQUEST['do'])? trim($_REQUEST['do']) : "";
$image_name = isset($_REQUEST['image_name'])? trim($_REQUEST['image_name']) : "";
switch ($do) {
*case "":
**?>
**<html>
**<form action="index.php">
**<input name="do" type="hidden" value="upload">
**<input name="image_name" type="file" size="15">
**<input type="submit" value="Upload">
**</form>
**</html>
**<?
**break;
*case "upload":
**if(!copy($image_folder, $image_name))
**{
***echo "could not upload";
**}
**break;
}
?>
note * = tab
Mr. Gecko
Check out this thread and message 29 by Birdman:
[webmasterworld.com...]
It may be of some use to you.
dc
[php.net...]
your code above has quite a few issues, your best bet would be to go with one of the 2 links mentioned and use their examples, they already work. ;)
<?
$form = "<html>
**<form action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\">
**<input name=\"do\" type=\"hidden\" value=\"upload\">
**<input name=\"image_name\" type=\"file\" size=\"30\">
**<br><label title=\"Overwrite file(s) if exist\" for=\"overwrite\"> Overwrite</label><input style=\"border:0px; background-color:#F7F6F4;\" type=\"checkbox\" name=\"overwrite\" id=\"overwrite\" value=\"1\">
**<br><input type=\"submit\" value=\"Upload\">
**</form>
**</html>";
$image_folder = "./image";
$do = isset($_REQUEST['do'])? trim($_REQUEST['do']) : "";
$image_name = isset($_REQUEST['image_name'])? trim($_REQUEST['image_name']) : "";
switch ($do) {
*case "":
**echo $form;
**break;
*case "upload":
**$allowed = array("gif", "jpg", "png", "bmp", "jpe", "jpeg", "tif");
**
**$current_image = 'image_name';
**
**$image = $_FILES[$current_image]['tmp_name'];
**$image_name = $_FILES[$current_image]['name'];
**$image_name = str_replace(" ", "_", $image_name);
**
**$img_name_arr = explode(".",$image_name);
**$type = end($img_name_arr);
**
**if($image_name == ""){ $img_result .= "<br><font color=\"red\">Image dose not exist try again</font>"; }
**elseif(!isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "<br><font color=\"red\">$image_name -> Image already exist! try again</font>";}
**elseif(!(in_array($type, $allowed) or in_array(strtolower($type), $allowed)) ){
***$img_result .= "<br><font color=\"red\">$image_name ->This type of file is not allowed! try again</font>";
**} else {
***@copy($image, $image_folder."/".$image_name) or $img_result .= "<br><font color=\"red\">$image_name -> Couldn't copy image to server</font><br />Check if file_uploads is allowed in the php.ini file of your server";
***if(file_exists($image_folder."/".$image_name))
***{
****$img_result .= "<br><font color=\"green\">$image_name -> Image was uploaded</font>";
***} else {
****$img_result .= "<br><font color=\"green\">$image_name -> Image was not uploaded! try again</font>";
***}
**}
**echo $img_result;
**echo $form;
**echo "<hr><br>";
**echo $form;
**break;
}
?>
note * = tab
thanks for trying
Mr. Gecko