Jump to content

Add images help (explaination under code)


eramge11

Recommended Posts

<?php

/**
 * This is the model class for table "student_docs".
 *
 * The followings are the available columns in table 'student_docs':
 * @property integer $student_docs_id
 * @property string $doc_category_id
 * @property string $title
 * @property string $student_docs_desc
 * @property string $student_docs_path
 */
class StudentDocs extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return StudentDocs the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'student_docs';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('student_docs_path, doc_category_id, title,student_docs_submit_date', 'required','message'=>""),
			array('student_docs_desc', 'length', 'max'=>50),

			array('student_docs_path', 'file', 'types'=>'jpeg, jpg, pdf, txt, doc,docx, gif, png', 'maxSize'=>1024*1024*2, 'tooLarge'=>'The document was larger than 2MB. Please upload a smaller document.',),
			
			//array('title','CRegularExpressionValidator','pattern'=>'/^[a-zA-Z& ]+([-]*[a-zA-Z0-9 ]+)*$/','message'=>''),			
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('student_docs_id, student_docs_desc, student_docs_path, doc_category_id,student_docs_submit_date, title', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'student_docs_id' => 'Student Docs',
			'student_docs_desc' => 'Document Description',
			'student_docs_path' => 'Document',
			'doc_category_id' => 'Document Category', 
			'title' => 'Title',
			'student_docs_submit_date'=>'Submit Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('student_docs_id',$this->student_docs_id);
		$criteria->compare('doc_category_id',$this->doc_category_id,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('student_docs_desc',$this->student_docs_desc,true);
		$criteria->compare('student_docs_path',$this->student_docs_path,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	
}

Hello everyone! Please help save me because I am about to loose my mind.

 

First- I have a database for a company I have been working on and for this database one of the things they would like is to have a tab to add documents to a specific clients database profile. I have done all of that and added the tab to add documents however, it will not allow me to add the document. I have attached a picture to show you what the error is. Basically everything else is working fine- I give the file a name, description, date of upload, and all of that gives me the green arrow beside it saying its fine however, when I add the file (any file extension) it will give me a red "x" beside the file path saying it can't be added. (see picture adddocument.png to see the display).

 

Here is also the code that is controlling the document upload page- maybe I am missing something. Maybe you will be able to catch it before I will- I have been staring at this for days now trying to get it to work! Thanks for the help in advance!

 

 

 

 

post-173390-0-20557200-1414686365_thumb.png

Link to comment
Share on other sites

It looks like your file upload dialog is some sort of JavaScript plugin, right?  If so, your problem revolves around your configuration of the plugin and not the server-side PHP which processes the file.

 

Also, I am sure you already did so, the dialog seems to validate that only files of specific extensions could be uploaded.  You did try to upload these file types, right?

Link to comment
Share on other sites

Thanks for the reply! Correct, I did try uploading the files specified. It was still giving me the error. Unfortunately I purchased the script off a website to have and they do not offer support on setting it up. I guess I will have to look around for the javascript controlling it. Do you have any suggestions? Like I said I have been frustrated working on this small setback for weeks now.

Link to comment
Share on other sites

<div class="portlet box blue">
 <div class="portlet-title"><i class="fa fa-plus"></i><span class="box-title">Upload File to Incident</span>
</div>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'student-docs-trans-form',
	'enableAjaxValidation'=>true,
	'htmlOptions'=>array('enctype'=>'multipart/form-data'),
	'clientOptions'=>array('validateOnSubmit'=>true,'validateOnCnange'=>true),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<div class="row">
		<?php echo $form->labelEx($stud_doc,'doc_category_id'); ?>
		<?php echo $form->dropDownList($stud_doc,'doc_category_id',CHtml::listData(DocumentCategoryMaster::model()->findAll(),'doc_category_id','doc_category_name'),array('empty' => 'Select Category')); ?><span class="status"> </span>
		<?php echo $form->error($stud_doc,'doc_category_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($stud_doc,'title'); ?>
		<?php echo $form->textField($stud_doc,'title',array('size'=>17,'maxlength'=>20)); ?><span class="status"> </span>
		<?php echo $form->error($stud_doc,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($stud_doc,'student_docs_desc'); ?>
		<?php echo $form->textArea($stud_doc,'student_docs_desc',array('rows'=>3,'cols'=>16)); ?><span class="status"> </span>
		<?php echo $form->error($stud_doc,'student_docs_desc'); ?>
	</div>
	
	

	<div class="row">
		<?php echo $form->labelEx($stud_doc,'student_docs_submit_date'); ?>
		<?php 
			    $this->widget('CustomDatePicker', array(
			    'model'=>$stud_doc,
			    'attribute'=>'student_docs_submit_date',
			    'options'=>array(
			    'dateFormat'=>'dd-mm-yy',
			    'changeYear'=>'true',
			    'changeMonth'=>'true',
			    'showAnim' =>'slide',
			    'yearRange'=>'1900:'.(date('Y')+1),	
			    'buttonImage'=>Yii::app()->request->baseUrl.'/images/calendar.png',           
			    ),
			    'htmlOptions'=>array(
			    'style'=>'width:165px;vertical-align:top'
			    ),
           
			));
			
		?>
		
		<span class="status"> </span>
		<?php echo $form->error($stud_doc,'student_docs_submit_date'); ?>
	</div>
	
	<div class="row">	
		<?php echo $form->labelEx($stud_doc,'student_docs_path'); ?>
		<?php echo $form->fileField($stud_doc, 'student_docs_path',array('size'=>'15')); ?>
		<span class="status"> </span>
	      	<?php echo $form->error($stud_doc,'student_docs_path'); ?>
		
	</div>
	<div class="hint"><b>Hint:-</b> Upload Only Jpeg, Jpg, Pdf, Txt, Doc, Gif, Png Type Document</div>
	 <div> </div>
</div><!-- form -->
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Add' : 'Save', array('class'=>'submit')); ?>
 		<?php echo CHtml::link('Cancel', Yii::app()->request->urlReferrer , array('class'=>'btnCan')); ?>
	</div>

<?php $this->endWidget(); ?>
</div>

This is what is showing that is controlling the widget

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.