# how to upload image throu lightweight module plugin ?

**URL:** https://forum.shopware.com/t/how-to-upload-image-throu-lightweight-module-plugin/53322
**Category:** Plugins
**Created:** [7. Juni 2018 um 05:24 UTC](https://forum.shopware.com/t/how-to-upload-image-throu-lightweight-module-plugin/53322 "2018-06-07T05:24:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Rizwan](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@Rizwan](https://forum.shopware.com/u/Rizwan)
#### Post date: [7. Juni 2018 um 05:24 UTC](https://forum.shopware.com/t/how-to-upload-image-throu-lightweight-module-plugin/53322/1 "2018-06-07T05:24:55Z")

</div>

Hello sir !I have made a image upload plugin and it has made thro shopware lightweight module but i have in trouble when i upload image&nbsp;

1)how to define a path where my image has to be physically save&nbsp;

2)how to save this this image name&nbsp;into database and then how to retrive it as well in any page&nbsp;

i have installed lightweight plugin and used as well but their is no option such like that so kindly help me sir my action is :&nbsp;

```
**public function** setAction() { //$basePath = $this-\>request-\>getBasePath().'/media/upload/'; $uploadedFile = ''; /\*if(!empty($\_FILES["file"]["type"])){ $fileName = time().'\_'.$\_FILES['file']['name']; echo $fileName;die(); $temporary = explode(".", $\_FILES["file"]["name"]); $sourcePath = $\_FILES['file']['tmp\_name']; $targetPath = $this-\>request-\>getBasePath().'/media/upload/'. $fileName; if(move\_uploaded\_file($sourcePath,$targetPath)){ $uploadedFile = $fileName; } }\*/ $name = $this-\>Request()-\>getParam('name'); //$image = $this-\>Request()-\>$fileName; $articleid = $this-\>Request()-\>getParam('articleid'); $image = $this-\>Request()-\>file\_put\_contents('file', 'name'); **echo** $image; **die** (); $desc = $this-\>Request()-\>getParam('desc'); $desclong = $this-\>Request()-\>getParam('desclong'); $sts = $this-\>Request()-\>getParam('sts',0); $sql = "insert into bcgh\_custom\_data (name,article\_id, description, descriptionLong,active,image) values ('{$name}', {$articleid}, '{$desc}', '{$desclong}',{$sts},'{$image}')"; var\_dump($sql); **die** (); $data = Shopware()-\>Db()-\>exec($sql); /\*return $this-\>redirect( array( 'controller'=\> 'ExampleModulePlainHtml', 'action' =\> 'index')

```

);

}

what would i used here properly&nbsp;

my input field name is „image“ my target action is setAction

Thanks&nbsp;
