另一个域上传文件,我需要移动在域中的所有上传的文件,所有的网站将成为另一个域
但在同一台服务器的IP,所以如何编辑上传过程上传文件 直接“文件域“?在同一台服务器
EX:
网站域名:doamin.com
文件域:myfiles.com
在正常的方式这是我的代码:
查看
...........
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'Cfiles-form',
'enableAjaxValidation'=>false,
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true), //This is very important
'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); ?>
<div class="row">
<?php echo $form->labelEx($model,'file'); ?>
<?php echo $form->fileField($model,'file'); ?>
الملفات المسموحة : jpg,gif, png,pdf,rar,zip,doc,docx
<?php echo $form->error($model,'file'); ?>
</div>
...............
控制器
public function actionCreate()
{
..................
.
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if(isset($_POST['Cfiles']))
{
$model->attributes=$_POST['Cfiles'];
$valdiate=$model->validate();
/////// upload image functions
$rnd = rand(0,999984375); // generate random number between 0-9999
$model->attributes=$_POST['Cfiles']['file'];
$uploadedFile=CUploadedFile::getInstance($model,'file');
if(!empty($uploadedFile)){
$ext=$uploadedFile->getExtensionName();
$fileName = "isa$rnd.{$ext}"; // random number + file name
}
////////// end
if($model->save()){
$f_id=$model->primaryKey;
................
if(!empty($uploadedFile)) // check if uploaded file is set or not
{
$uploadedFile->saveAs(Yii::app()->basePath.'/../cfillaf/'.$fileName); // upload image to server
$model->file = $fileName;
$model->save(false);
}
....................
}
在此先感谢
只是chge文件路径,确保文件\目录权限允许该 – 2013-05-22 09:30:34
衮:你可以给我的例子吗?谢谢你 –