另一個域上傳文件,我需要移動在域中的所有上傳的文件,所有的網站將成爲另一個域
但在同一臺服務器的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
袞:你可以給我的例子嗎?謝謝你 –