In my module, I’m trying to send a picture to $_FILES then retrieve it and put it in a specific folder. However, when I try it shows up that $_FILES is empty. I tried using print_r and echo count() but they just returned empty arrays and 0. This code is the code for the cp backend page. help?
<?php
if (isset($_POST['xsubmit']))
{
echo count($_FILES);
echo count($_FILES['upload']);
print_r($_FILES);
print_r($_FILES['upload']);
$image=$_FILES['upload']['name'];
$folder='';
if ($image)
{
$filename=$folder . $image;
copy($_FILES['upload']['tmp_name'],$filename);
}
}
?>
<?= form_open('C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=picture_uploader')//sets homepage and opens form?>
<span>Upload</span> your pictures here.
<?= form_upload(array('name'=>'upload','enctype'=>'multipart/form-data','class'=>'file','value'=>'Choose picture'))//file select button?>
<?= form_submit(array('name' => 'xsubmit', 'value' => 'Upload', 'class' => 'submit'))//creates submit button?>
<?= form_close()//closes form?>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.