User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,584 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,077 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 956 | Replies: 4
Reply
Join Date: Aug 2007
Posts: 21
Reputation: rime is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rime rime is offline Offline
Newbie Poster

image upload problem

  #1  
Oct 13th, 2007
I have written the following image upload code:

image_upload.html:

<html>
<head>
</head>
<body>
<form method="post" action="check_image.php" enctype="multipart/form-data">
<table border="0" cellpadding="5">
<tr>
<td>Image title or caption</td>
<td><input name="image_caption" type="text" id="image_caption" size="55" maxlength="255" /></td>
</tr>
<tr>
<td>Your user name:</td>
<td><input name="image_username" type="text" id="image_username" size="55" maxlength="255" /></td>
</tr>
<tr>
<td>Upload image:</td>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<td><input name="image_filename" type="file" id="image_filename"></td>
</tr>
</table>
<br>

<p align="center"><input type="submit" name="Submit" value="Submit">
&nbsp;<input type="reset" name="Submit2" value="Clear Form">
</p>
</form>
</body>
</html>



check_image.php:

<?

include('../functions.php');
mysql_connect("loaclhost","username","password")
or die("Failure to communicate");
mysql_select_db("db")
or die("Could not connect to Database");

$image_caption = $_POST['image_caption'];
$image_username = $_POST['image_username'];
$image_caption = $_FILES['image_filename']['name'];
$today = date("Y-m-d");
$ImageDir = "D:/uploads/";
$ImageName = $ImageDir . $image_tempname;
if(move_uploaded_file($_FILES['image_filename']['tmpname'],$ImageName)){
list($width, $height, $type, $attr) = getimagesize($ImageName);

switch($type){
case 1:
$ext = ".gif";
break;

case 2:
$ext = ".jpg";
break;

case 3:
$ext = ".png";
break;

default :
echo "Sorry";}}
print_r($_FILES);


?>


And its giving the following output:

Array ( [image_filename] => Array ( [name] => little-baby-monkeys.jpg [type] => image/pjpeg [tmp_name] => C:\PHP\uploadtemp\php1839.tmp [error] => 0 [size] => 105075 ) )


Can anyone please help me? its urgent..
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Posts: 137
Reputation: mostafadotnet is on a distinguished road 
Rep Power: 3
Solved Threads: 7
mostafadotnet's Avatar
mostafadotnet mostafadotnet is offline Offline
Junior Poster

Re: image upload problem

  #2  
Oct 13th, 2007
You said that your code output is:
Array ( [image_filename] => Array ( [name] => little-baby-monkeys.jpg [type] => image/pjpeg [tmp_name] => C:\PHP\uploadtemp\php1839.tmp [error] => 0 [size] => 105075 ) )

And it's pretty obvious that the:
		 print_r($_FILES);
function would print this output.
What is your actual problem?


!!!
Reply With Quote  
Join Date: Aug 2007
Posts: 21
Reputation: rime is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
rime rime is offline Offline
Newbie Poster

Re: image upload problem

  #3  
Oct 14th, 2007
Originally Posted by mostafadotnet View Post
You said that your code output is:
Array ( [image_filename] => Array ( [name] => little-baby-monkeys.jpg [type] => image/pjpeg [tmp_name] => C:\PHP\uploadtemp\php1839.tmp [error] => 0 [size] => 105075 ) )

And it's pretty obvious that the:
		 print_r($_FILES);
function would print this output.
What is your actual problem?


!!!





My problem is that it is not uploading any images
Reply With Quote  
Join Date: Jan 2008
Posts: 7
Reputation: fedderico10 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
fedderico10 fedderico10 is offline Offline
Newbie Poster

Re: image upload problem

  #4  
May 12th, 2008
Did you find the answer to your problem? i have the same error and i haven't find any solution please help.
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 251
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 12
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: image upload problem

  #5  
Oct 13th, 2007
<?php include("dbcon.php"); ?> //db settings here
<?php
//--------------------------------------------------------------------------------
$path = "D:\websites\mysite.com\Uploads\\";
$web = "../uploads/";
$nopic = "../images/nopic.jpg";
$ad = "add_item";
$no = "1";
$page = $ad.$no;
//--------------------------------------------------------------------------------
$isim = $_REQUEST['NewsID']; // isim stands for renaming.
$tip = $_FILES[img1][type]; // tip = type
$size = $_FILES[img1][size];
//--------------------------------------------------------------------------------
$Edit = $_COOKIE['Edit'.$no];
if($Edit != "")
{
$GetID = "select * from news where NewsID='" . $isim . "'";
$FindID=mysql_query($GetID);
while($WriteID = mysql_fetch_array($FindID))
{
if($WriteID['Resim'.$no] != "")
{
setcookie('Edit'.$no,'');
$dosya = $WriteID['Resim'.$no];
}
else
{
setcookie('Edit'.$no,'');
$dosya = $nopic;
}
}
}
//--------------------------------------------------------------------------------
elseif($size >= 150000)
{
$dosya = $nopic;
//Temizle
$sil1 = $isim."_".$no.".jpg";
$sil2 = $isim."_".$no.".png";
$sil3 = $isim."_".$no.".gif";
@unlink($path.$sil1);
@unlink($path.$sil2);
@unlink($path.$sil3);
$uyari = "<small>Max 150Kb</small>";
}
//--------------------------------------------------------------------------------
elseif($tip == "image/jpeg" || $tip == "image/pjpeg")
{
$dosya = $isim."_".$no.".jpg";
//Temizle
$sil1 = $isim."_".$no.".jpg";
$sil2 = $isim."_".$no.".png";
$sil3 = $isim."_".$no.".gif";
@unlink($path.$sil1);
@unlink($path.$sil2);
@unlink($path.$sil3);
// Veritabanina Yaz
$query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
mysql_query($query) or die(mysql_error());
//Kopyala
@copy($_FILES[img1][tmp_name],$path.$dosya);

}



i wrote this one last year and still use it... dont say pls, it doesnt work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC