Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method and steps of uploading pictures successfully in CodeIgniter

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "successful method steps of uploading pictures in CodeIgniter". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

The copy code is as follows:

/* Note, here is userfile,$this->upload->do_upload(), here do_upload default upload file form name is userfile;

Do_upload($filename) can also be used, where $filename must match the string in form_upload().

I am here Fan confused, finally read the manual to understand, I hope you pay attention to Oh!

*/

Controller Code:

function upload() {

$config['upload_path'] = './ uploads/';

The requested URL/uploads/index.php was not found on this server.

"The upload path does not appear to be valid. ";

*/

$config['allowed_types'] = 'gif|jpg|png';

/* I try to upload other types of files, be sure to pay attention to the order here!

A problem was encountered while attempting to move the uploaded file to the final destination.

This error is generally uploaded file name can not be Chinese name, this is very depressed! Not resolved, we can use other methods, to change the file name can be resolved!

$config['allowed_types'] = 'zip| gz| png| gif| jpg';(correct)

$config['allowed_types'] = 'png| gif| jpg| zip| gz';(error)

*/

$config['max_size'] = '1024';

$config['max_width'] = '1024';

$config['max_height'] = '768';

$config ['file_name'] = time(); //file name does not use original name

$this->load->library('upload', $config);

if(!$ this->upload->do_upload()) {

echo $this->upload->display_errors();

}else{

$data ['upload_data']=$this->upload->data(); //some information about the file

$img=$data <$'upload_data']<$'file_name']; //get file name

echo $img. "

";

foreach($data['upload_data'] as $item => $value){

echo $item. ":".$ value. "

";

}

}

}

"How to upload pictures successfully in CodeIgniter" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report