I am trying to upload files using laravel5.1.But i am facing error like
FatalErrorException in Handler.php line 25:
Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in E:\xampp\htdocs\mp-admin\vendor\compiled.php on line 1720 and defined in E:\xampp\htdocs\mp-admin\app\Exceptions\Handler.php:25
Stack trace:
#0 E:\xampp\htdocs\mp-admin\vendor\compiled.php(1720): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
thrown
Here is my view
<div class="form-group">
<label >Logo</label>
<input type="file" name="image" >
</div>
Controller:
$entry = new companyprofiles();
$file = Input::get('image');
$extension = $file->getClientOriginalExtension();
Storage::disk('local')->put($file->getFilename().'.'.$extension, File::get($file));
$entry->mime = $file->getClientMimeType();
$entry->original_filename = $file->getClientOriginalName();
$entry->filename = $file->getFilename().'.'.$extension;
$entry->save();
But first when i was trying it was storing in database and folder as well.after that continuously giving the same above error.
Please help me with this.if i do dd the value also its giving me the same error i could not able to find where is the error.Not getting stored in database.
Remove or delete vendor/compile.php
Run composer dump-autoload
if not work then
run composer update
Related
Can someone please help me in uploading file in Podio? I am new in Podio library so I am trying but getting lots of errors.
Warning: realpath() expects parameter 1 to be a valid path, resource given in /home/gphxyz/public_html/decode/podio-php/models/PodioFile.php on line 54
Warning: filesize() expects parameter 1 to be a valid path, resource given in /home/gphxyz/public_html/decode/podio-php/models/PodioFile.php on line 54
Fatal error: Uncaught PodioBadRequestError: "'source' parameter must given as multipart/form-data with type 'file'"
Request URL: http://api.podio.com/file/v2/
Stack Trace: #0 /home/gphxyz/public_html/decode/podio-php/lib/Podio.php(352): Podio::request('POST', '/file/v2/', Array, Array)
#1 /home/gphxyz/public_html/decode/podio-php/models/PodioFile.php(54): Podio::post('/file/v2/', Array, Array)
#2 /home/gphxyz/public_html/decode/podio-php/index.php(22): PodioFile::upload(Resource id #72, 'http://geeksper...')
#3 {main} thrown in /home/gphxyz/public_html/decode/podio-php/lib/Podio.php on line 289
My code is below:
<?php
require_once 'PodioAPI.php';
//Initalize Podio connection
$client_id = '';
$client_secret = "";
Podio::setup($client_id, $client_secret);
//App ID's
$opname_app_id = '21209880';
$opname_app_token = "";
Podio::authenticate_with_app($opname_app_id, $opname_app_token);
$opname_auth = Podio::$oauth;
$filepath = 'http://geeksperhour.xyz/decode/podio-php/credit.jpg';
$filename = 'credit.jpg';
$goFile = PodioFile::upload($filepath, $filename);
$fileID = $goFile->file_id;
print_r($fileID);
You might find that lib/podio.php for file uploads is deprecated since a while.
See the open Ticket on Github: The usage of the #filename API for file uploading is deprecated - File upload #74
Changing the API in line 189 will allow you to follow the documentation again.
from
if (!empty($options['upload'])) {
curl_setopt(self::$ch, CURLOPT_POST, TRUE);
curl_setopt(self::$ch, CURLOPT_SAFE_UPLOAD, FALSE);
curl_setopt(self::$ch, CURLOPT_POSTFIELDS, $attributes);
self::$headers['Content-type'] = 'multipart/form-data';
}
to
if (!empty($options['upload'])) {
$cfile = curl_file_create(substr($attributes[ "source" ], 1));
// Assign POST data
$attributes[ "source" ] = $cfile;
curl_setopt(self::$ch, CURLOPT_POST, TRUE);
curl_setopt(self::$ch, CURLOPT_POSTFIELDS, $attributes);
self::$headers['Content-type'] = 'multipart/form-data';
}
Worked for me in a PHP 7.2 Ubuntu 16.04 environment.
Also make sure the path to your file is pointing to local a path of your server.
Additional if you use composer you might find it useful to point to the master rather than the latest release:
composer require podio/podio-php:dev-master
As error message says: expects parameter 1 to be a valid path, resource given in /home/gphxyz/public_html/decode/podio-php/models/PodioFile.php on line 54
So, please provide valid local file path instead of $filepath = 'http://geeksperhour.xyz/decode/podio-php/credit.jpg';
I am having an issue with my Google+ Api. It was working fine, but suddenly stopped retrieving data from Google+ page.
This is the code, which was working fine and nothing is changed in it.
<?php
$guserid = get_field('google_plus_user_id','option');
$gplus_api = get_field('google_plus_api_key','option');
if(empty($guserid))
$guserid = "***ID***";
if(empty($gplus_api))
$gplus_api = "***API***";
$gactivity_url = "https://www.googleapis.com/plus/v1/people/".$guserid."/activities/public?maxResults=1&key=".$gplus_api;
$gactivity = json_decode(file_get_contents($gactivity_url));
$items = $gactivity->items[0];
$created_time = $items->updated;
$link = $items->url;
$title = $items->title;
$attachments = $items->object->attachments[0];
$full_picture = $attachments->image->url;
?>
<img src="<?php echo $full_picture; ?>" alt="Google+"/>
<div class="gp_content">
<div><?php echo $attachments->content ?></div>
<a target="_blank" href="<?php echo $link; ?>"><?php echo $title; ?> </a>
<dt> <?php echo date('d/m/Y', strtotime($created_time)); ?> </dt>
I am receiving the following errors
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114
Warning: file_get_contents(): Failed to enable crypto in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114
Warning: file_get_contents(https://www.googleapis.com/plus/v1/people/USERID/activities/public?maxResults=1&key=APIKEY): failed to open stream: operation failed in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 114
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 115
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 117
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 118
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 119
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 121
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 121
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 122
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 122
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 126
Notice: Trying to get property of non-object in C:\Inetpub\vhosts\abc.com\httpdocs\fc\wp-content\themes\abc\social-feeds-tpl.php on line 126
Any help is appreciated.
This should do it:
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
]
]);
$data = file_get_contents($gactivity_url, false, $context);
Good Day I've alter the website_hr_recruitment module to add some function to download some file. But an Error has occcured when I try to download the file without user access. The error is
{"message": "Odoo Server Error", "code": 200, "data": {"debug": "Traceback (most recent call last):\n File \"/opt/odoo/odoo-server/addons/web/controllers/main.py\", line 70, in wrap\n return f(*args, **kwargs)\n File \"/opt/odoo/odoo-server/addons/web/controllers/main.py\", line 1092, in saveas\n res = Model.read(cr, uid, [int(id)], fields, context)[0]\n File \"/opt/odoo/odoo-server/openerp/api.py\", line 268, in wrapper\n return old_api(self, *args, **kwargs)\n File \"/opt/odoo/odoo-server/openerp/addons/base/ir/ir_attachment.py\", line 318, in read\n self.check(cr, uid, ids, 'read', context=context)\n File \"/opt/odoo/odoo-server/openerp/api.py\", line 268, in wrapper\n return old_api(self, *args, **kwargs)\n File \"/opt/odoo/odoo-server/openerp/addons/base/ir/ir_attachment.py\", line 260, in check\n raise except_orm(_('Access Denied'), _(\"Sorry, you are not allowed to access this document.\"))\nexcept_orm: (u'Access Denied', u'Sorry, you are not allowed to access this document.')\n", "exception_type": "except_osv", "message": "Access Denied\nSorry, you are not allowed to access this document.", "name": "openerp.exceptions.except_orm", "arguments": ["Access Denied", "Sorry, you are not allowed to access this document."]}}
Heres the Model
#http.route('/jobs/apply/<model("hr.job"):job>', type='http', auth="public", website=True)
def jobs_apply(self, job):
error = {}
default = {}
#Added by SDS 19022016
attachment = http.request.env['ir.attachment'].sudo().search([('name', '=', 'Application-Form-rev2.docx')])
#str_url = 'http://localhost:8069'+'/web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attachment.id)
str_url = request.httprequest.host_url +'web/binary/saveas?model=ir.attachment&field=datas&filename_field=name&id='+str(attachment.id)
if 'website_hr_recruitment_bahia_error' in request.session:
error = request.session.pop('website_hr_recruitment_bahia_error')
default = request.session.pop('website_hr_recruitment_bahia_default')
return request.render("website_hr_recruitment_bahia.apply", {
'job': job,
'error': error,
'default': default,
'url_link': str_url,
})
and heres the Template
<div t-attf-class="form-group #{error.get('first_name') and 'has-error' or ''}">
Click ”<a t-att-href="url_link" >Apply Now</a> ” to download, fill-out and upload below
<label class="col-md-3 col-sm-4 control-label" for="first_name">First Name</label>
<div class="col-md-7 col-sm-8">
<input type="text" t-att-value="default.get('first_name')" class="form-control" name="first_name" required="True"/>
</div>
</div>
I tried to add the sudo access but it has no use can someone help me
Thanks
Please create a security file named - ir.model.access.csv
Add it in __openerp__.py like this -
'data': [
'security/ir.model.access.csv',
'views/your_view.xml',
]
Above security is the folder name and in it the file ir.model.access.csv exist.
And add following lines to your csv file-
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_YOUR_CLASS_NAME,access_YOUR_CLASS_NAME,model_YOUR_CLASS_NAME,,1,1,1,1
This should solve the access problem.
Unfortunately, v8 has a more restrictive policy on ir.attachment object and it only let Employee (base.group_user) group read all document i.e. user have to be logged in to access the document(s). So adding record rule or Access Control List rule will not help you.
The best solution here it's to over-ride the def check method on ir.attachment and make more relax to checking the security of accessing documents publically, or maybe you can just over-ride and do not put any logic and make object security driven by ir.attachment. or you can also let some model document bypass from security check.
Hope this will help you.
Bests
Im using 000webhost as a way to host my portfolio of websites. However Im getting this error thrown in which doesn't happen to me on localhost.
Notice (8): Undefined index: Upload [APP/Controller/UploadsController.php, line 32]
This is the code it seems to be referring to,
public function add() {
$this->render();
if($this->request->is('post')){
$file = $this->request->data['Upload']['file'];
if($this->Upload->save($this->data) && move_uploaded_file($file['tmp_name'],APP.'webroot/files/uploads'.DS.$this->Upload->id.'.mp4'))
{
$this->Session->setFlash('<p class="uploadflash">The upload has been saved</p>', true);
$this->redirect(array('controller'=>'Uploads', 'action' => 'watch', $this->Upload->id));
} else {
$this->Session->setFlash('<p class="loginerror">The upload could not be saved, mp4 files can be saved only.</p>', true);
}
}
}
Any ideas as to why this is happening?
Also in addition my Elements are not showing up on this online hosting either?
I get thrown this error on the page
Element Not Found: Elements/uploads/recentuploads.ctp
Does anyone else seem to have this problem??
Upon further inspection I have found that the server does not allow file upload sizes to exceed 2mb, in this instance PHP throws the error above.
After doing my code update. I got this error.
Could you help me figure this one out?
I gave 777 permission to all of the folders.
Thanks in advance!
Fatal error: Uncaught exception 'Zend_Cache_Exception' with message
'cache_dir must be a directory' in
C:\xampp\htdocs\mts\library\Zend\Cache.php:208 Stack trace: #0
C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php(154):
Zend_Cache::throwException('cache_dir must ...') #1
C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php(121):
Zend_Cache_Backend_File->setCacheDir('C:\xampp\htdocs...') #2
C:\xampp\htdocs\mts\library\Zend\Cache.php(152):
Zend_Cache_Backend_File->__construct(Array) #3
C:\xampp\htdocs\mts\library\Zend\Cache.php(93):
Zend_Cache::_makeBackend('File', Array, false, false) #4
C:\xampp\htdocs\mts\application\Bootstrap.php(22):
Zend_Cache::factory('Core', 'File', Array, Array) #5
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\BootstrapAbstract.php(636):
Bootstrap->_initCache() #6
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\BootstrapAbstract.php(589):
Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('cache') 7#
C:\xampp\htdocs\mts\library\Zend\Application\Bootstrap\Boots in
C:\xampp\htdocs\mts\library\Zend\Cache.php on line 208
Setting the cache in bootstrap
protected function _initCaching() {
$frontend = array(
'lifetime' => 7200,
'automatic_serialization' => true
);
$backend = array(
'cache_dir' => sys_get_temp_dir(), /**automatically detects**/
);
$cache = Zend_Cache::factory('core', 'File', $frontend, $backend);
Zend_Registry::set('cache', $cache);
}
Go to C:\xampp\htdocs\mts\library\Zend\Cache\Backend\File.php at line 154 and echo $value before the conditions. It should give you a directory address. Make sure that directory exists in your file system. Basically you need to set this path correctly in your zend configuration.
It's not about permission, ZF can't find the cache directory. Check if the directory you set in application.ini actually exists.
As you are on Windows machine, permissions shouldn't be a problem.