I've tried using the upload class to upload an image, however, the image doesn't get moved to the server or even starts to upload.
I can't make sense of this:
https://area51.phpbb.com/docs/dev/3.2.x ... index.html#
Can anybody help, please?
Code: Select all
$picupload = (isset($_POST['picupload'])) ? true : false;
if ($picupload == true) {
$action = request_var('action', '');
switch ($action)
{
case 'upload':
//Our main code goes in here
if (!class_exists('fileupload'))
{
include($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
}
//Set upload directory
$upload_dir = 'images/';
//Upload file
$upload = new fileupload();
$upload->set_allowed_extensions(array('png', 'jpg', 'jpeg'));
$file = $upload->form_upload('picupload');
if (empty($file->filename))
{
trigger_error( 'File upload failed.' . adm_back_link($this->u_action), E_USER_WARNING);
}
$file->move_file($upload_dir, true);
$gameimagenamefile = $file->filename;
include("dbconnectfile.php");
$addgame = "INSERT INTO indielix_gameimages (GameID, GameImage) VALUES ('$gameidnumber', '$gameimagenamefile')";
if($conn->query($addgame)){
$message = "Image added to game! $gameimagenamefile";
writeSMes($message);
}
else{
$message = "Error adding image to game!";
writeEMes($message);
}
$conn->close();
break;
}
}
Here is the form:
Code: Select all
<div class="col-sm-2">
<form action="" method="post" enctype="multipart/form-data" id="picupload" name="picupload">
<input type="hidden" name="tempid" value="'.$row3['GameID'].'_'.$row3['GameName'].'"></input>
<p>Select image to upload:</p>
<input type="file" name="gameimgfileToUpload" id="gameimgfileToUpload"><br></br>
<input type="submit" class="btn btn-primary" value="Upload Image" id="picuploaded" name="picuploaded">
</form>
</div>
Any help would be greatly appreciated as I'm pulling my hair out over this.
Cheers