Jump to content

Warning: image_type_to_extension() expects parameter 1 to be long, string given


Alex1646

Recommended Posts

Here is the error:

Warning: image_type_to_extension() expects parameter 1 to be long, string given in C:\wamp\www\Login\inc\edit-profile.php on line 23

Here is the code for line 23:

$type = image_type_to_extension($_FILES['pic']['type'], true);

Here is the code for the whole page:

<?php
if(!$userb)
{
login('?p=edit-profile');	
die();
}
if(isset($_POST['submit']))
{
$mottof = mysql_real_escape_string(bb($_POST['motto']));
$aboutf = mysql_real_escape_string(bb($_POST['about']));
$interesrsf = mysql_real_escape_string(bb($_POST['interests']));
$booksf = mysql_real_escape_string(bb($_POST['books']));
$authorsf = mysql_real_escape_string(bb($_POST['author']));
$randf = mysql_real_escape_string(bb($_POST['random']));
if($_FILES['pic']['type'] == 'image/gif' || $_FILES['pic']['type'] == 'image/jpeg' || $_FILES['pic']['type'] =-'image/pjpeg' || $_FILES['pic']['type'] == 'image/png')
{
if($_FILES['pic']['size'] < 8388608)
{
if($_FILES['pic']['name'] != '')
{

//mkdir('/images/user_images/' .$user_log);
$type = image_type_to_extension($_FILES['pic']['type'], true);
move_uploaded_file($_FILES['pic']['tmp_name'], 'images/user_images/' .$user_log .'pp' .$type);
$path = 'images/user_images/' .$user_log .'pp' .$type;
}
else 
{
$path = 'images/user_images/user.jpg';}
}
$q2 = "UPDATE login_info
SET profile_picture = '$path'
WHERE user='$user_log'

";
mysql_query($q2) or die(mysql_error());


}


$query = "
UPDATE login_info
SET motto = '$mottof', about = '$aboutf', fav_books = '$booksf', fav_authors = '$authorsf', interests = '$interesrsf', random = '$randf'
WHERE user='$user_log'
";	
mysql_query($query);






echo '<h3> Profile Updated </h3>';
}
$q = "SELECT * FROM login_info WHERE user='$user_log' ";
$s = mysql_query($q) or die(mysql_error());
$r = mysql_fetch_assoc($s);
$motto = $r['motto'];
$about = $r['about'];
$books= $r['fav_books'];
$authors = $r['fav_authors'];
$rand = $r['random'];
$interests = $r['Interests'];
if(isset($_GET['act'])){$red = '?p=' .$rpage ;} else {$red='?p=edit_profile';}
echo"

<form action='?p=edit-profile' enctype='multipart/form-data' method='post' >
<label>Motto: </label>
<input type='text' name='motto' value='$motto' placeholder='Motto' />
<label> About :</label>
<textarea name='about' cols='40' rows='10'> $about</textarea>
<label> Interests: </label>
<textarea name='interests' cols='40' rows='10'> $interests </textarea>
<label> Favorite Books: </label>
<textarea name='books' cols='40' rows='10'> $books </textarea>
<label> Favorite Authors </label>
<textarea name='author' cols='40' rows='10'> $authors </textarea>
<label> Random: </label>
<textarea name='random' cols='40' rows='10'> $rand </textarea>
";
?>
<script type='text/javascript'>
function if_checked()
{
if($('#cur').is(':checked'))
{
$('#pic').attr('disabled', true);
}
else
{
$('#pic').removeAttr('disabled');	
}
}
</script>
<label> Profile Picture: </label>
<input type='checkbox' name= 'current' id='cur' onchange="if_checked();" checked /> <label for='current' style='display:inline;'> Current profile picture </label> <br />
<input type='file' id='pic' name='pic' disabled="disabled" />
<br />
<input type='submit' value ='Submit' name='submit' />
</form>

Ive used the function before and I havent encountered this error. Im not sure what it means.

Link to comment
Share on other sites

string image_type_to_extension ( int $imagetype [, bool $include_dot = TRUE ] )

 

First one should be in integer.

 

I don't have time to look through your entire code, but just to give you a heads up - The mime-type PHP gives is BASED on the extension of the file uploaded, and not the content. Verifying that you have the correct extension by using the image's mime-type is therefor redundant.

 

You only need to check for extensions, unless your server executes files such as JPG/GIF/PNG etc. as if it were code. Malicious code uploaded as a JPG file should only ever output as a broken JPG, and never actually get executed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.