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 426,629 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 1,594 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: 1049 | Replies: 4
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  

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

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

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

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