Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Image uploading

max_file_size

  • Please log in to reply
4 replies to this topic

#1 Whitey

Whitey

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 259 posts

Posted 23 July 2008 - 12:26 PM

the form
	<form action='process.php' name='form1' method='post'>
<table width='470' border='0' cellspacing='1' cellpadding='0' id='profile_table'>
<tr bgcolor='#333333'>
<td width='100' height='25' id='profile_table'><div align='right'>Main Game: </div></td>
<td height='25' id='profile' style='padding-left:30px;'>
<input name='MAX_FILE_SIZE' value='2097152' type='hidden'>
<input name='image' type='file' size='34' accept='image/jpeg, image/gif, image/png'>
</td>
</tr>
</table>
</form>





process.php

		if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];

// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);
$config->query("UPDATE `members` SET picture = '$data' WHERE username = '$username'");
}



but the isset($_FILES['image']) is not working its saying its not set..
  • 0

#2 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 23 July 2008 - 12:38 PM

What does:

accept='image/jpeg, image/gif, image/png'>

do? I've never heard of that before. I can't really see anything wrong. Maybe it's because of the accept attribute?
  • 0

#3 Whitey

Whitey

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 259 posts

Posted 23 July 2008 - 01:01 PM

That has it accpeting only images that are jpeg gif and png

EDIT: figured it out i was missing ENCTYPE in my form tag
  • 0

#4 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 23 July 2008 - 01:14 PM

Well even without enctype, I wasn't getting any errors so I have no idea. :s

Glad you got it figured out. Since it's using a class and databases, I thought maybe a problem with the class or database.
  • 0

#5 Guest_Jaan_*

Guest_Jaan_*
  • Guest

Posted 24 July 2008 - 02:05 AM

That has it accpeting only images that are jpeg gif and png

EDIT: figured it out i was missing ENCTYPE in my form tag


yes.. you have to have this enctype.. like this:

<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" /><br />
<input type="submit" value="Upload" />
</form>

  • 0





Also tagged with one or more of these keywords: max_file_size

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download