CodeIgniter File Upload In Hindi.

हेलो दोस्तों आज के इस ब्लॉग पोस्ट(CodeIgniter File Upload In Hindi) में हम आपको CodeIgniter में file uploading functionality बताने जा रहे है |

दोस्तों ऐसे कई प्रकार के form होते है जिनमे user से फाइल को अपलोड कराने की जरुरत पड़ती है |CodeIgniter File Upload In Hindi|

और इसके लिए हमें अपने form में file uplod की facility build करनी पड़ती है |CodeIgniter File Upload In Hindi|

तो चलिए इस ब्लॉग पोस्ट में हम आपको CodeIgniter framework के साथ यह फाइल uploading application बताने जा रहे है |CodeIgniter File Upload In Hindi|

यह ब्लॉग और functionality आपके लिए बहुत ही इंटरेस्टिंग रहने वाली है |CodeIgniter File Upload In Hindi|

CodeIgniter में file upload class का use करके हम फाइल upload कर सकते है |

और यहाँ तक कि हम user को file के size और type के बेस्ड पर restrict कर सकते है |

CodeIgniter में फाइल uploading को समझने और सीखने के लिए आप नीचे दिए गए प्रोसेस follow करिये :

Example:

नीचे दिए गए code को कॉपी करिये और इसे application /View /Upload _form .php में स्टोर करिये|

<html>
 
   <head> 
      <title>Upload Form</title> 
   </head>
	
   <body> 
      <?php echo $error;?> 
      <?php echo form_open_multipart('upload/do_upload');?> 
		
      <form action = "" method = "">
         <input type = "file" name = "userfile" size = "20" /> 
         <br /><br /> 
         <input type = "submit" value = "upload" /> 
      </form> 
		
   </body>
	
</html>

नीचे दिए गए कोड को कॉपी करिये और उसे application /View /Upload _success.php में स्टोर करिये|

<html>
 
   <head> 
      <title>Upload Form</title> 
   </head>
	
   <body>  
      <h3>Your file was successfully uploaded!</h3>  
		
      <ul> 
         <?phpforeach ($upload_data as $item => $value):?> 
         <li><?php echo $item;?>: <?php echo $value;?></li> 
         <?phpendforeach; ?>
      </ul>  
		
      <p><?php echo anchor('upload', 'Upload Another File!'); ?></p>  
   </body>
	
</html>

नीचे दिए गए कोड को कॉपी करिये और उसे application /controllers /Upload.php में स्टोर करिये|

एक uploads folder क्रिएट करिये CodeIgniter के रुट में कहने का मतलब application फोल्डर की parent डायरेक्टरी में|

<?php
  
   class Upload extends CI_Controller {
	
      public function __construct() { 
         parent::__construct(); 
         $this->load->helper(array('form', 'url')); 
      }
		
      public function index() { 
         $this->load->view('upload_form', array('error' => ' ' )); 
      } 
		
      public function do_upload() { 
         $config['upload_path']   = './uploads/'; 
         $config['allowed_types'] = 'gif|jpg|png'; 
         $config['max_size']      = 100; 
         $config['max_width']     = 1024; 
         $config['max_height']    = 768;  
         $this->load->library('upload', $config);
			
         if ( ! $this->upload->do_upload('userfile')) {
            $error = array('error' => $this->upload->display_errors()); 
            $this->load->view('upload_form', $error); 
         }
			
         else { 
            $data = array('upload_data' => $this->upload->data()); 
            $this->load->view('upload_success', $data); 
         } 
      } 
   } 
?>

application /config /routes.php में रूट फाइल के अंदर निम्नलिखित change करिये|

और नीचे दी गयी lines को फाइल के end में add करिये |

$route['upload'] = 'Upload';

अब इस कोड example को execute कीजिये नीचे दिए गए URL को विजिट करके |

यहाँ पर yoursite .com से अपने URL को replace करिये|

http://yoursite.com/index.php/Upload

इसका output स्क्रीन आप नीचे देख सकते है :

file upload screen
file upload screen: CodeIgniter File Upload In Hindi

और एक बार आप फाइल को successfully अपलोड कर देते है उसके बाद आपको यह screen दिखाई देगी:

after file uploaded successfully
after file uploaded successfully

you can also go through a few more amazing blog posts by clicking the below blog links related to Codeigniter:

What is temp data in Codeigniter in Hindi…
FlashData In CodeIgniter In Hindi…
Session Management In CodeIgniter In Hindi…
Form Validation In CodeIgniter In Hindi…
Email Sending In CodeIgniter In Hindi…
CodeIgniter File Upload In Hindi…
Error Handling Techniques In CodeIgniter In Hindi…
What are CodeIgniter Libraries In Hindi…
CodeIgniter Database Connection In Hindi…
CodeIgniter Configuration In Hindi…
CodeIgniter Basic Concepts In Hindi…
CodeIgniter MVC Framework In Hindi…
CodeIgniter Application Architecture In Hindi…
CodeIgniter Installation In Hindi…
CodeIgniter Tutorial for Beginners in Hindi…

इस ब्लॉग(CodeIgniter File Upload In Hindi) को लेकर आपके मन में कोई भी प्रश्न है तो आप हमें इस पते support@a5theory.comपर ईमेल लिख सकते है|

आशा करता हूँ, कि आपने इस पोस्ट(CodeIgniter File Upload In Hindi) को खूब एन्जॉय किया होगा|

आप स्वतंत्रता पूर्वक अपना बहुमूल्य फीडबैक और कमेंट यहाँ पर दे सकते है|

आपका समय शुभ हो|

Anurag

I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.