Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: talross on October 19, 2014, 12:49:43 AM

Title: [Solved]
Post by: talross on October 19, 2014, 12:49:43 AM
SMF: 2.0.9
PHP version: 5.3.28
MySQL version: 5.5.37-35.0

I found another way to make it all work and come together. Thanks for the help, though. :)
Title: Re: Uploading and using cover image for hover mini-profile
Post by: Sir Osis of Liver on October 19, 2014, 01:17:31 AM
See if any of this helps with your uploader script -



$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$uploaded_name = basename( $_FILES['uploaded']['name']) ;
$uploaded_type = $_FILES['uploaded']['type'];
$uploaded_size = $_FILES['uploaded']['size'];
$songtitle = $_POST['songtitle'];

$ok=1;

if ($uploaded_name == "")
{
echo 'Please select a file to upload.';
$ok=0;
$duh=1;
}

else

if (($uploaded_type != "image/x-png")
&& ($uploaded_type != "image/png")
&& ($uploaded_type != "image/gif")
&& ($uploaded_type != "image/bmp")
&& ($uploaded_type != "image/jpeg")
&& ($uploaded_type != "image/pjpeg")
&& ($uploaded_type != "audio/mpeg")
&& ($uploaded_type != "audio/x-mpeg")
&& ($uploaded_type != "audio/mp3")
&& ($uploaded_type != "audio/x-mp3")
&& ($uploaded_type != "audio/mpeg3")
&& ($uploaded_type != "audio/x-mpeg3")
&& ($uploaded_type != "audio/mpg")
&& ($uploaded_type != "audio/x-mpg")
&& ($uploaded_type != "audio/x-mpegaudio")
&& ($uploaded_type != "audio/x-amzaudio")
&& ($uploaded_type != "video/x-ms-wmv")
&& ($uploaded_type != "video/avi"))

{
echo "File type &nbsp<b><font face='arial'>" . $uploaded_type . "</font></b>&nbsp is not allowed." . "<br><br>";
$ok=0;
}



There are several png and jpg mime types.  The last line will echo the type being refused.
Title: Re: Uploading and using cover image for hover mini-profile
Post by: talross on October 19, 2014, 01:36:37 AM
I added:
if (($uploaded_type != "image/x-png")
&& ($uploaded_type != "image/png")
&& ($uploaded_type != "image/gif")
&& ($uploaded_type != "image/bmp")
&& ($uploaded_type != "image/jpeg")
&& ($uploaded_type != "image/pjpeg")
/*&& ($uploaded_type != "audio/mpeg")
&& ($uploaded_type != "audio/x-mpeg")
&& ($uploaded_type != "audio/mp3")
&& ($uploaded_type != "audio/x-mp3")
&& ($uploaded_type != "audio/mpeg3")
&& ($uploaded_type != "audio/x-mpeg3")
&& ($uploaded_type != "audio/mpg")
&& ($uploaded_type != "audio/x-mpg")
&& ($uploaded_type != "audio/x-mpegaudio")
&& ($uploaded_type != "audio/x-amzaudio")
&& ($uploaded_type != "video/x-ms-wmv")
&& ($uploaded_type != "video/avi")*/)

{
echo "File type &nbsp<b><font face='arial'>" . $uploaded_type . "</font></b>&nbsp is not allowed." . "<br><br>";
$ok=0;
}


In place of:
if (!($uploadFile_type == "image/png")) {
    echo "Sorry, only PNG files are allowed.";
    $uploadOk = 0;
}


And got the error:
"File type    is not allowed.

Sorry, your file was not uploaded."

I tried uploading a .png and .jpg image.
Title: Re: Uploading and using cover image for hover mini-profile
Post by: Sir Osis of Liver on October 19, 2014, 03:19:48 PM
Is it echoing a file type?  Did you define $uploaded_type at top of script?



$uploaded_type = $_FILES['uploaded']['type'];



Title: Re: Uploading and using cover image for hover mini-profile
Post by: talross on October 19, 2014, 03:42:46 PM
Derp. Yeah. Got that part in and the "File type    is not allowed" went away.

Still got the "Sorry, your file was not uploaded" though, with no other error saying why. Gonna play with it some more and see if I can't straighten it out.
Title: Re: [Solved]
Post by: Bigguy on October 19, 2014, 10:12:58 PM
This thread would have been a lot better if the title had been left intact and the solution to whatever the problem was remained. As it stands right now this thread is not very useful.
Title: Re: [Solved]
Post by: talross on October 19, 2014, 10:38:56 PM
The solution was a completely different workaround, and I don't necessarily trust the way I bootlegged it enough to leave up for someone else to stumble into.
Title: Re: [Solved]
Post by: Bigguy on October 19, 2014, 10:44:40 PM
OK, good answer. :)