Im using codeigniter framework,
I have two folders in my public html folder,one contains the main website and other have mobile website
Both having same database
The issue that im facing is,
i want to upload a file from mobile website which should be uploaded in the folder which can be accessible for both sites(mobile and main).
While uploading from mobile site ,it only uploading inside the mobile folder(mobile site)
Some one please tell me how can i upload the file outside the mobile folder(mobile web root),im really struggling in it.
Fileshould upload outside the root folder
Give below is the code i am using
if($_FILES["resumecar"]["name"]){
$file = basename($_FILES['resumecar']['name']);
$ext = end(explode('.', $file));
$ext = strtolower($ext);
$filename = "resume_".time().'.'.$ext;
move_uploaded_file($_FILES["resumecar"]["tmp_name"],"uploads/careers/".$filename);
$uploadfile = "uploads/careers/".$filename;
}else{$filename = '';}
Related
I am trying fetch doc content from google drive using the Google sdk. The problem is, the get() function is not working properly. It gives only file metadata not any actual content.
$googl = new Googl();
$this->client = $googl->client();
$this->client->setAccessToken(session('user.token'));
$this->drive = $googl->drive($this->client);
$file = $this->drive->files->get("fileId");
return $file;
From the documentation it looks like you can download a file using:
$file = $this->drive->files->get("fileId", array('alt' => 'media'));
$content = $file->getBody()->getContents();
I suspect that we may have a language issue here.
Read the content from a Google drive file
The google drive api is a file datastore api. This means that it stores the file itself and the information about said file. It does not give you any access to the contents of that file.
If you want to know what is in the file you will need to download the file and open it up on your machine.
or try Google documents api however i suspect that it will only be able to read a google drive document file and not a word file you may have to convert it first.
download the the file
If you check the documentation for Download Files you will find the following.
$fileId = '0BwwA4oUTeiV1UVNwOHItT0xfa2M';
$response = $driveService->files->get($fileId, array(
'alt' => 'media'));
$content = $response->getBody()->getContents();
I have an external hosting server.
On that server I have 2 domains:
www.dom1.com
www.dom2.com
On www.dom1.com I have my whole web page (in Codeigniter). One of the functionalities is upload (users can upload their files.)
On www.dom2.com there is only one folder called upload_dom2. www.dom2.com is otherwise empty and not visible anywhere on the Internet. I would like to use it exclusively for upload. I imagine that this is a much safer way than letting the users upload their files on www.dom1.com where all my other files are (by the way, let me know if I'm wrong, please).
So, how do I do that? How do I upload a file - that user has uploaded in the framework of Codeignitors system (webpage) on www.dom1.com - in a folder called upload-dom2 on www.dom2.com
I know how to upload a file in a folder called uplod_dom1 that is located on www.dom1.com. This is a code that I use.
$pathd=$_SERVER['DOCUMENT_ROOT'];
$config['upload_path'] = $pathd.'/upload_dom1';
But as said, that is not what I want. I want to upload to www.dom2.com (in its uplod-dom2 folder).
May I know what is the correct way to achieve my objective?
Take a look at the Codeigniter FTP class. You can do this with any external website/server that supports FTP: http://ellislab.com/codeigniter/user-guide/libraries/ftp.html
Example code:
$this->load->library('ftp');
$config['hostname'] = 'ftp.example.com';
$config['username'] = 'your-username';
$config['password'] = 'your-password';
$config['debug'] = TRUE;
$this->ftp->connect($config);
$this->ftp->upload('/local/path/to/myfile.html', '/public_html/myfile.html', 'ascii', 0775);
$this->ftp->close();
In a Struts 1 Web App I can access images from a .jsp by
<img src="../../images/myImageName.png"/>
Am I also able to reference that image from a .java class in my source directory?
I am using iText and can fetch an image from a url
String imageUrl = "http://jenkov.com/images/" +
"20081123-20081123-3E1W7902-small-portrait.jpg";
Image image2 = Image.getInstance(new URL(imageUrl));
but if I try and fetch one from
Image image = Image.getInstance("../../images/myImageName.png"/);
It always looks in the bin folder of my server. How can I get the relativePath back to my image?
If the image is in the web app content directory then you need the app context relative path:
String relativeWebPath = "images/myImageName.png";
String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
Would I do that? Not unless there's a good reason; I'd prefer either a path off the app context altogether (and the image could be streamed by the app, or set as a symlink, etc) or a classpath-based resource.
I've uploaded them to a public folder. Everything works apart from these two.
Is there some extra "Google Drive Hosting" script I need to put in?
Or should it be working without any extra and I need re-check my code?
Many thanks!
me also faced same problem while uploading my custom Jquery Plugin, bt i can able upload js file to an existing folder which is already using for my previous project , me faced this problem while creating new folder only
but
In my new folder me just deleted that js file and uploaded it again ,its working fr me nw
save file as .js
content of that file
(function ( $ ) {
$.fn.doValidation = function(options) {
//ur code goes here
}( jQuery ));
Hi i am making a simple component in joomla having name image detail and i have to upload that image how can i upload image from backend. which one is better using extension or make custom. can you please share any good article for it. i have searched many more but due to lack of idea on joomla cannot find. hope you genius guys help me.
thanks i advance
Joomla Component for the exact scenario of your requirement will be very hard to find out. So you've two options:
1. Make your own component
2. Customize other similar type of component like gallery component
For uploading file from joomla component on admin if you're making your own component:
1. Just use move_uploaded_file php function.
2. copy this code, for joomla's standard fxn :
function upload($src, $dest)
{
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$ret = false;
$dest = JPath::clean($dest);
$baseDir = dirname($dest);
if (!file_exists($baseDir)) {
jimport('joomla.filesystem.folder');
JFolder::create($baseDir);
}
if ($FTPOptions['enabled'] == 1) {
jimport('joomla.client.ftp');
$ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
$dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/');
if (is_uploaded_file($src) && $ftp->store($src, $dest))
{
$ret = true;
unlink($src);
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
} else {
if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors
if (JPath::setPermissions($dest)) {
$ret = true;
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR01'));
}
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
}
return $ret;
}
If you want to use other's component and edit it according to need, download it:
http://prakashgobhaju.com.np/index.php?option=com_showcase_gallery&view=items&catid=1&Itemid=64
Remember it's a gallery component.
Uploading any file be it an image on your Joomla site is something which is so simple, and can be done using either the web based FTP and or the desktop FTP services like filezilla but only when you have saved the file you want to upload. Using the web based way, you need to log in to your host for example 000webhost, locate the file manager option, click on it and enter your domain username and password. Then go to public_html folder , create a new folder for your photos or images and click on upload. Locate your image and click on the tick link to start uploading.
Using the desktop way, you will need to unzip your file to add to joomla, open your FTP client like filezilla, locate the file on local host, input your log in details as provided by your host and once you are logged in to your account through filezilla, locate where you want to add the file and click on upload.
You can find a similar tutorial with regard here http://www.thekonsulthub.com/how-tos/how-to-upload-joomla-with-filezilla-to-your-hosting-servers-cpanel/ {entire thing}
Please please please make sure you use the filtering available in the MediaHelper. Specifically never trust uploaded images, always check first that they are valid file types, then that they are in the list of approved types of files listed in your global configuration, that the names do not contain html or javascript, and that the files themselves do not contain code. In particular I would recommend the MediaHelper::canUpload method which will check the majority of these things for you. If anything you should be checking even more strongly. Also make sure that you are checking whether the user has permission to upload. If anything you should make the checking even more restrictive. Use the APIs that joomla gives you, such as the built in media field.