Page 1 of 1

Image Upload Function (Advanced) (w/ resize)

Posted: Mon Mar 29, 2004 4:54 pm
by Sybatical
I recently download the above script at Evil Walrus

But having trouble getting it to work. -_-

Posted: Mon Mar 29, 2004 5:10 pm
by Illusionist
uhm... ok.... What 'trouble' are you having?

Posted: Mon Mar 29, 2004 5:17 pm
by Sybatical
I upload the file and nothing shows up.

Eg. Here

Posted: Mon Mar 29, 2004 5:36 pm
by Illusionist
uhh... most likely if you download a script, theres going to be a few things taht your going to have to edit to work on your server. have you edited anything at all?? Or did you just download that script and upload it to your server and don't know anything about php to fix anything?? and why did you name it +resize).php??

Posted: Mon Mar 29, 2004 5:39 pm
by Sybatical
Not new to php.
<?PHP
function image_upload($userfile, $newfile, $directory, $width, $height, $quality='100', $smooth='10', $extention='AUTO') {
$imgsize = GetImageSize($userfile);
if (($imgsize[0] > $width) || ($imgsize[1] > $height)) {
$tmpimg = tempnam("/tmp", "MKUP");
system("djpeg $userfile >$tmpimg");
system("pnmscale -xy $width $height $tmpimg | cjpeg -smoo $smooth -qual $quality >$userfile");
unlink($tmpimg);
};
$mimetype = $_FILES['userfile']['type'];

if ($extention == "AUTO") {
if (($mimetype == "image/x-png") || ($mimetype == "image/png")){
$extention = "png";
}elseif ($mimetype == "image/pjpeg"){
$extention = "jpg";
}elseif ($mimetype == "image/gif"){
$extention = "gif";
}else{
$extention = "";
$error_message = "Please upload images with the extension .jpg or .jpeg or .gif or .png only";
};
};
if (strstr($mimetype, "image/")) {
$newfile_name = $newfile.".".$extention;
$newfile = $directory.$newfile_name;
if (is_uploaded_file($userfile)){
if (!copy($userfile, $newfile)) {
$error_message = "Error Uploading File.";
};
};
return $newfile_name;
}else{
$error_message = "Not An Image";
};
};

//EXAMPLE

image_upload($_FILE['userfile'], "Avatar-123", "images/avatars/", 90, 90, 100, 0)
?>
Cant work how to fix it. I cant see any MySQL tags etc

Oh and +resize) is the downloaded name

Posted: Mon Mar 29, 2004 5:39 pm
by Illusionist
LOL, no wonder nothign comes up. Nothing is supposed to. All that is, is an upload and resize function. You have to write everythign else - like the form.....

Posted: Mon Mar 29, 2004 5:41 pm
by Sybatical
Damn! I new something was wrong! :P

Posted: Mon Mar 29, 2004 5:42 pm
by PrObLeM
and you dont need this in there its just an example

Code: Select all

<?php
//EXAMPLE

image_upload($_FILE['userfile'], "Avatar-123", "images/avatars/", 90, 90, 100, 0)
?>

Posted: Mon Mar 29, 2004 5:42 pm
by Illusionist
Sybatical wrote:Not new to php.
If your not a n00b, i think you would have noticed that all that is is a function, and nothing will show up unless you build an application around that function. And if you don't know anything about functions and/or forms and/or php, i would suggest go and reading some tutorials and trying small things on your own, and not just downloading scripts and asking why they dont work.

Posted: Mon Mar 29, 2004 5:45 pm
by Sybatical
The description said nothing about function.
function image_upload($userfile, $newfile, $directory, $width, $height, $quality='100', $smooth='10', $extention='AUTO') {
I should have looked at it first.

I think I'll take the avatar browser from a phpbb forum. ;)

Posted: Mon Mar 29, 2004 5:51 pm
by Illusionist
I should have looked at it first.
That just shows that you are a n00b and don't know what your doing. Someone who knows PHP or any programnming language and wants to learn more will take the time to learn it. But its people like you that all you do is take other's scripts that look nice, ask for help to get them to work, call them yours, and never learn anything.

Posted: Mon Mar 29, 2004 5:58 pm
by Sybatical
Thats the first script i have actually downloaded. O.o

I asked for help, not to be flamed.

Posted: Mon Mar 29, 2004 7:19 pm
by m3mn0n
Most of those open source ones are posted with little or no documentation. The author pretty much intends the snipplet of code to be used by a more experienced user of the language.

You shouldn't feel bad making a mistake while you're learning, no big deal there. I'm sure everyone has, and it's good that you do make mistakes. That way you will know what not to do, and how to do it better next time.

Illusionist: You should be a bit more tollerant to newbie mistakes, no matter how embarrassing/obvious they are. I'm sure you made them too, so ease up a bit. Sheesh.

Posted: Mon Mar 29, 2004 9:06 pm
by Cruzado_Mainfrm
i don't understand why ppl have to be so bad against newbies, just like ppl are in high school against the freshmen, YOU WERE ONE TOO. Maybe somebody treated you that way when you were a noob, geez...

And also, for you people that are really newbies into any kind of subject/matter, stop saying you are a newbie and you don't know anything! because, u might get stuck with the noob thing... and then u will need another nickname to disguise ;)

Posted: Mon Mar 29, 2004 9:29 pm
by Illusionist
Well, it bugs me how he says he wasn't a n00b, but it was obvious he was...