Yii Framework Forum: [EXTENSION] CFile - Yii Framework Forum

Jump to content

  • (5 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] CFile Rate Topic: -----

#81 User is offline   idle sign 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 18-September 09
  • Location:Novosibirsk, Russia

Posted 02 November 2011 - 02:26 AM

View Postkoras, on 02 November 2011 - 01:50 AM, said:

Please provide an example of an entry in the file because it does not find examples.

sorry for my english


What entry do you mean?
You can use your native language as a fallback %)
0

#82 User is offline   koras 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-October 11
  • Location:moscow

Posted 02 November 2011 - 03:03 AM

english
If you attempt to write to the file, frays. I can not understand how to add content to the file. I would like to see an example of this kind.
russia

При попытке записи в файл, файл перетирается. Не могу понять, как именно добавить контент в конец файла. Хотелось бы увидеть пример именно такого рода.

$cfile = Yii::app()->file->set('/var/www/test/file.conf');
$cfile ->setContents('content');


What am I doing wrong?
Что я делаю неправильно?

I'm sorry, I haven't got a lot of speaking practise.

Только что увидел в профиле Новосибирск ), сразу повеяло чем то родным
0

#83 User is offline   koras 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-October 11
  • Location:moscow

Posted 02 November 2011 - 03:41 AM

to the end file content
example

Quote

$cfile = Yii::app()->file->set('/var/www/test/sip.conf');
$cfile ->setContents('content','',FILE_APPEND);

thank you idle sign
0

#84 User is offline   idle sign 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 18-September 09
  • Location:Novosibirsk, Russia

Posted 02 November 2011 - 04:31 AM

View Postkoras, on 02 November 2011 - 03:41 AM, said:

$cfile = Yii::app()->file->set('/var/www/test/sip.conf');
$cfile ->setContents('content','',FILE_APPEND);



The second param should be a boolean, not a string to make it the right way. E.g.:

$cfile->setContents('content', true, FILE_APPEND);

0

#85 User is offline   mwrn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 30-November 11

Posted 10 December 2011 - 05:31 AM

Hi, thanks for the great extension

how to return only sub directory in get content?
i have a code like this
$cfileDir = Yii::app()->file->set('/mydir');
print_r($cfileDir->getContents(true));

0

#86 User is offline   idle sign 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 18-September 09
  • Location:Novosibirsk, Russia

Posted 11 December 2011 - 09:41 AM

View Postmwrn, on 10 December 2011 - 05:31 AM, said:

how to return only sub directory in get content?


Do you mean how to get only the contents of a directory? Obviously do not use a recursion, i.e. set $recursive param of getContents() to False.
0

#87 User is offline   mwrn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 30-November 11

Posted 12 December 2011 - 02:58 AM

View Postidle sign, on 11 December 2011 - 09:41 AM, said:

Do you mean how to get only the contents of a directory? Obviously do not use a recursion, i.e. set $recursive param of getContents() to False.


Hi, thanks. It works. Never thought of that ^^
0

#88 User is offline   rongusya 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 26-January 12

Posted 07 February 2012 - 01:09 AM

how create new folder with CFile
0

#89 User is offline   viktor_au 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 14-February 13

Posted 14 February 2013 - 04:58 AM

Hi
I installed the extension and checked it with some examples. It works.
I have a question.
How can I let user to download audio (zipped) file?
I managed to get the filtered file name (view-controller-model-view):
$file = CHtml::encode($data->file);

But I cannot use it in the code:

$cfileDir = Yii::app()->file->set('c://xampp/htdocs/files/audio/');
$myfile = Yii::app()->file->set('$cfileDir', true);
$myfile->download('$file', true);

As I mentioned above it works when I use the file name in example (I have dialog popped up):
$myfile->download('myfastfile.txt', true);

However I cannot succeed to insert $file in place of 'myfastfile.txt'.

Can somebody please help?

Thanks.
0

#90 User is offline   Thureos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 13-February 12

Posted 03 July 2013 - 02:11 PM

Hi,

First of all, thanks for this class...

I've found an error in setContents method:

If I set autocreate to true, it never creates the file because it validates if is a file before and that will never happen.

Sorry for my english!

Thanks again!
0

#91 User is offline   paskuale 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 399
  • Joined: 30-December 11
  • Location:Italy, Bari

Posted 24 July 2014 - 07:10 AM

Hi, there's small sample, for create a new file and write in it ? At the end, I wish send it for download ;) thanks

[solved]
$webroot = Yii::getPathOfAlias('webroot');
$path = $webroot . DIRECTORY_SEPARATOR . 'downloads' . DIRECTORY_SEPARATOR . 'paco.dat';


$cfile = Yii::app()->file->set($path);
if($cfile->create()){
$cfile ->setContents($file_content,true, FILE_APPEND);
}

//CVarDumper::dump($cfile,10,true);die();
//for send to browser
$cfile->send();
0

Share this topic:


  • (5 Pages)
  • +
  • « First
  • 3
  • 4
  • 5
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users