Printing the web path of the file just uploaded |
[eluser]heretic[/eluser]
Hi everyone, I already managed to upload files using this guide: http://ellislab.com/codeigniter/user-gui...ading.html You can find a demo at http://www.dustskill.com/index.php/upload/ What i am now trying to do is to make it show the web adress of the uploaded file on upload_success.php It already shows information about the uploaded file there . For example, when the file name.txt is uploaded to /uploads, the actual file path would be /home/dustskill/uploads/name.txt. Resulting of this, the web adress would be dustskill.com/uploads/name.txt Any Suggestions? Thanks a lot in advance!
[eluser]ciGR[/eluser]
Hi and welcome! You can use the Code: $data = $this->upload->data(); Code: $data['full_path'] => /path/to/your/upload/image_name.jpg Code: $upload_dir = './uploads/'; check the http://ellislab.com/codeigniter/user-gui...ading.html, in the $this->upload->data() section
[eluser]heretic[/eluser]
Thanks a lot for the fast reply! I am not really experienced in PHP (to be honest, im a bloody beginner). Could you tell me how to implement this code? Thanks a lot!
[eluser]ciGR[/eluser]
In your controller, after the successful image upload. read the http://ellislab.com/codeigniter/user-gui...ading.html will help you!
[eluser]heretic[/eluser]
[quote author="ciGR" date="1269723607"]In your controller, after the successful image upload. read the http://ellislab.com/codeigniter/user-gui...ading.html will help you![/quote] i have read the guide, i said so in my first post. Could you give me step-by-step instructions? Looks like I still cant get it to work.
[eluser]heretic[/eluser]
It is basically the same code than in the guide except for a little hack i made to allow any filetype to be uploaded. Heres the code Code: <?php
[eluser]ciGR[/eluser]
Code: <?php
[eluser]heretic[/eluser]
this does completely make sense to me but i still cant get it to work. you can have a look at the rest of code following my link in the first post.
[eluser]ciGR[/eluser]
[quote author="heretic" date="1269791099"]this does completely make sense to me but i still cant get it to work. you can have a look at the rest of code following my link in the first post.[/quote] As I can see the erros I get are about don't pass the variables to your view. for example: Quote:Message: Undefined variable: upload_datameans that you try to access the variable $upload_data which not pass from your controller before. for example you must have Code: //in your controller Maybe you must read again the MVC, understand the mean of controllers, views, models. Also uncomment the Code: //$config['allowed_types'] = 'gif|jpg|png'; Never let the user upload whatever file_type want. |
Welcome Guest, Not a member yet? Register Sign In |