Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old October 23rd, 2009, 03:35 PM   #1
New Member
 

Join Date: Apr 2008
Location: US
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 mars is on a distinguished road
Problem Uploading files

I got this file, but i got this error and i don't get why that happens.

Notice
: Undefined index: uploaded in C:\wamp\www\insert\insert2.php on line 25.
"$ext = findexts($_FILES['uploaded']['name']) ;"


Code:

<?php
$connection 
mysql_connect("localhost","root","");
if (!
$connection) {
    die(
"wrong connection: " mysql_error());
}


$db_select mysql_select_db("images",$connection);
if (!
$db_select) {
    die(
"error: " mysql_error());
}
?>
<?php

function findexts ($filename)
{
$filename strtolower($filename) ;
$exts split("[/\\.]"$filename) ;
$n count($exts)-1;
$exts $exts[$n];
return 
$exts;



$ext findexts($_FILES['uploaded']['name']) ;  //here is the error
$ran rand () ;
$ran2 $ran.".";
$target "C:/wamp/www/images/";
$target $target $ran2.$ext


if(isset(
$_POST['submit']))
{
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo 
"The file has been uploaded as ".$ran2.$ext;
}
else
{
echo 
"Sorry, there was a problem uploading your file.";
}

$rename $ran2.$ext;
$query "INSERT INTO images (name) VALUES ('$rename')";
mysql_query($query) or die('Error, query failed : ' mysql_error());
}
?> 

<html>
<body>

<form method="post" enctype="multipart/form-data" action="insert2.php">
<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="246">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input name="uploaded" type="file" id="uploaded">
</td>
<td width="80"><input name="submit" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>
</body>
</html>
<?php 
if(isset($connection)){
   
mysql_close($connection); 
}
?>
mars is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
uploading files Phixon Flash and ActionScript 3 November 14th, 2007 07:43 AM
uploading files ziggi PHP 8 May 30th, 2007 04:16 PM
Uploading various image files Paula .NET 1 October 7th, 2006 04:39 PM
files not uploading skyfire400 Web Hosting and Domains 1 March 4th, 2006 02:30 PM
Uploading of files gwx03 Implemented Suggestions 6 December 24th, 2003 05:51 PM


Search Engine Optimization by vBSEO 3.2.0 RC8