MyBB Community Forums

Full Version: Not uploading.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sorry if this is the wrong section.

So I've coded this but it doesn't wanna upload for some reason.
Any idea guyes?

if (!$mybb->input["action"])
{
    // Form
    $form = new Form("index.php?module=mytest-addimg&action=add", "POST", "mytest", 1);

    // Container
    $form_container = new FormContainer("Add New Image");
    $form_container->output_row("Upload Image:", '', $form->generate_file_upload_box('upimg', '', array('id' => 'upimg')), 'upimg');

    // End Container
    $form_container->end();

    // Buttons
    $buttons = array();
    $buttons[] = $form->generate_submit_button("Upload");
    $buttons[] = $form->generate_reset_button("Reset");
    $form->output_submit_wrapper($buttons);
    $form->end();
}
else if ($mybb->input["action"] == "add")
{
    // Variables
    $f_Directory = MYBB_ROOT."/imgfolder/";
    $f_Target = $f_Directory.basename($_FILES["upimg"]["name"]);
    $f_Extension = pathinfo(f_Target, PATHINFO_EXTENSION);
    
    // Check Extension
    if($f_Extension != "jpg")
    {
        // Message
        flash_message("Invalid file selected, only JPG files accepted.", 'error');
        admin_redirect('index.php?module=mytest-addimg');
    }
    else
    {
        if(move_uploaded_file($_FILES["upimg"]["tmp_name"], $f_Target))
            flash_message("File uploaded!", 'success');
        else
            flash_message("Failed uploading!", 'error');

        admin_redirect('index.php?module=mytest-addimg');
    }
} 
Amazing support guyes (sarcasm level 9000)

I'll use standard html instead of this mybb crap code.
Have patience, soon someone will reply with a possible solution.
I have fixed it myself.
(2016-05-09, 02:01 PM)BearMan Wrote: [ -> ]Amazing support guyes (sarcasm level 9000)

I'll use standard html instead of this mybb crap code.

Support is provided free by a community of volunteers. No one here is getting paid to provide support, and with that attitude you shouldn't expect anyone to want to help you in the future either.
For those that have a similar issue, MYBB_ROOT already has a trailing slash so don't add another one right after it:

$dir = MYBB_ROOT.'mydirectory';
not
$dir = MYBB_ROOT.'/mydirectory';

Hey OP this is free software, feel free to pay me money and I'll fix your stuff for you. Otherwise quit whining.
(2016-05-10, 11:52 PM)fizz Wrote: [ -> ]For those that have a similar issue, MYBB_ROOT already has a trailing slash so don't add another one right after it:

$dir = MYBB_ROOT.'mydirectory';
not
$dir = MYBB_ROOT.'/mydirectory';

Hey OP this is free software, feel free to pay me money and I'll fix your stuff for you. Otherwise quit whining.

That wasn't the issue and never will be.
Only problem was i was doing tests on localhost and it didn't work, so I tested on my live forum and worked fine.
So my code was always correct.
(2016-05-11, 11:03 AM)BearMan Wrote: [ -> ]
(2016-05-10, 11:52 PM)fizz Wrote: [ -> ]For those that have a similar issue, MYBB_ROOT already has a trailing slash so don't add another one right after it:

$dir = MYBB_ROOT.'mydirectory';
not
$dir = MYBB_ROOT.'/mydirectory';

Hey OP this is free software, feel free to pay me money and I'll fix your stuff for you. Otherwise quit whining.

That wasn't the issue and never will be.
Only problem was i was doing tests on localhost and it didn't work, so I tested on my live forum and worked fine.
So my code was always correct.

So you was at fault for not testing in a correct environment.