Tuesday, 15 January 2013

php - Codeigniter Upload image and insert to my folder -


I am working with codeigniter and I have a form where I can add a new item.

In this form, I have an area where I can upload an image and put it into my database.

All the work is fine to incorporate into my database.

My question is, how can I add the image that I have uploaded to my folder?

Path: nameofproject / imagens / banner /

Here's my controller:

  Function Novo () {$ this-> Load-> Assistant (array ('form', 'url')); $ This- & gt; Load-> Library ('form_validation'); $ This- & gt; Form_validation- & gt; Set_relets ('banda', 'banda', 'required'); $ This- & gt; Form_validation- & gt; Set_reales ('data', 'data', 'required'); $ This- & gt; Form_validation- & gt; Set_riels ('hora_incoo', 'horror inad', 'required' numeric '); $ This- & gt; Form_validation- & gt; Set_resells ('horror_fim', 'hora fame', 'required | numerical'); $ This- & gt; Form_validation- & gt; Set_Rials ('Morada', 'Morada', 'Required'); $ This- & gt; Form_validation- & gt; Set_reales ('preco', 'preva,', 'required, numeric'); $ This- & gt; Form_validation- & gt; Set_riels ('aquisao_bilhetes', 'aqui� ¿half o delhas', 'required'); $ This- & gt; Form_validation- & gt; Set_riels ('descricao', 'observer § μes', 'required'); $ This- & gt; Form_validation- & gt; Set_reales ('image', 'image', 'required | [image / jpeg | image / png] | file_path [../../ fancy / banner /]'); If (! $ This-> Input-> Post ()) {$ this- & gt; Load-> Scene ("concert"); } And {$ dados = $ this- & gt; Input-> Post (); $ This- & gt; Load-> Model ("Dados_model"); $ Result = $ this- & gt; Grandfather_model- & gt; Inner ($ Daedoz); }}    

Do you want to store the context of your image in the database (i.e. : You have a column that is a filename and you store it: myupload.jpg) or do you want to physically store the image in the database?

If it is already there, then you want to use it to get information about your file $ this-> Upload-> Data () Help Function

Cheers

No comments:

Post a Comment