Pregunta

I am using cakephp 2.1 and developing an application it contains more content. So I wanna use xml for uploading the content. Where in xml I am specifying url for image like this http://reelstubs.com/img/users/000da9c6dd7f9b7de04c7e17eb4d5e1e.jpg But I used cakephp uploader plugin from this website http://milesj.me/code/cakephp/uploader. for image upload so Its giving me an error like "Please upload image photo".

This plugin needs an array like

array(
   'name' => '', 
   'type' => '', 
   'tmp_name' => '', 
   'error' => '', 'size' => ''
 ).

So I am not getting like this when I am specifying url in xml. Please help me I am struggling from many days. The work will be more appreciable.

¿Fue útil?

Solución

You will have to download the image to a tmp location and set the tmp_name to that location. You can use file_get_contents from php or HttpSocket from cake.

You will need to avoid using the usual php is_uploaded checks as the file would not have been uploaded.

You will want to add a bit more security to make sure people dont put scripts or other things for uploading as that can be a security issue.

example using HttpSocket. After the upload is done you could do $Download->file->path() to get its location.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top