Laravel trying to store image file in 3 different folder - laravel

I'm trying to store image in 3 different folder inside public folder now I'm able to store in two different folder but when I added 3rd folder path but it was not coping in 3rd folder help me to solve this.
my two folder copying Working code
$input['student_photo'] = time().'.'.$request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // path 1
$request->student_photo->move($folder1, $input['student_photo']); // image saved in first folder
$path2 = public_path('public/path2/') . $input['student_photo']; // path 2
\File::copy($path1, $path2);
I tired this code for copy 3rd folder but not working
$input['student_photo'] = time().'.'.$request->student_photo->getClientOriginalExtension();
$folder1 = public_path('public/path1/');
$path1 = $folder1 . $input['student_photo']; // path 1
$request->student_photo->move($folder1, $input['student_photo']); // image saved in first folder
$path2 = public_path('public/path2/') . $input['student_photo']; // path 2
$path3 = public_path('public/path3/') . $input['student_photo']; // path 3
\File::copy($path1, $path2, $path3);

\File::copy($path1, $path2);
\File::copy($path1, $path3);


laravel how to save files with predefined name

in laravel controller i am trying to give each video file i uploading should be rename as
and save in public folder.
but my present code makes random number for my files but i need to give name as myfile
my controller
$input['file_id'] = time() . '.' . $request->file_id->getClientOriginalExtension();
$folder1 = public_path('/public');
$path1 = $folder1 . $input['file_id']; // path 1
$request->file_id->move($folder1, $input['file_id']);
What you want is :
$input['file_id'] = 'myfile.'.$request->file_id->getClientOriginalExtension();
But you cannot give the same name 'myfile' to all your videos because each recording will be overwritten by the previous one, you need unique names.
For this you can do, for example:
$input['file_id'] = 'myfile'.time().'.'.$request->file_id->getClientOriginalExtension();
// here, time() represents the time at which the video was saved in your '/public' file
$input['file_id'] = 'myfile'.date().'.'.$request->file_id->getClientOriginalExtension();
// here, date() represents the date the video was saved in your '/public' file

how to zip multiple folders in codeigniter

I am trying to zip multiple folders in codeigniter.
here is my code
public function zip_files()
$this->zip->compression_level = 0;
$path1 = '/my folder path';
$path2 = '/my another folder path';
but the above code zips only the $path2 folder.
how to zip multiple folders? this is my question
you can use clean data
example :
$name = 'my_bio.txt';
$data = 'I was born in an elevator...';
$this->zip->add_data($name, $data);
$zip_file = $this->zip->get_zip();
$name = 'photo.jpg';
$this->zip->read_file("/path/to/photo.jpg"); // Read the file's contents
You can use $this->zip->read_dir()
$path = '/path/to/your/directory/';
you have to supply base folder then it will zip all folders, files within it in single zip file.

Saving Intervention Image In Owners Folder in Laravel 5

I can change my code to save the uploaded image in the public dir but not when I want to their uploaded image in a folder as their company's name. For example of what works:
If the user's company name is Foo, I want this when they save save their uploaded image:
This is in my controller:
$image = Input::file('company_logo');
$filename = $image->getClientOriginalName();
$path = public_path('company_img/' . Auth::user()->company_name . '/' . $filename);
// I am saying to create the dir if it's not there.
File::exists($path) or File::makeDirectory($path); // this seems to be the issue
// saving the file
Image::make($image->getRealPath())->resize('280', '200')->save($path);
Just looking at that you can easily see what it's doing. My logs shows nothing and the browser goes blank after I hit the update button. Any ideas
File::exists($path) or File::makeDirectory($path);
This line does not make sense, as you check if a file exists and if not you want to attempt to create a folder ( in your $path variable you saved a path to a file not to a directory )
I would do something like that:
// directory name relative to public_path()
$dir = public_path("company_img/username"); // set your own directory name there
$filename = "test.jpg"; // get your own filename here
$path = $dir."/".$filename;
// check if $folder is a directory
if( ! \File::isDirectory($dir) ) {
// Params:
// $dir = name of new directory
// 493 = $mode of mkdir() function that is used file File::makeDirectory (493 is used by default in \File::makeDirectory
// true -> this says, that folders are created recursively here! Example:
// you want to create a directory in company_img/username and the folder company_img does not
// exist. This function will fail without setting the 3rd param to true
// is used by this function
\File::makeDirectory($dir, 493, true);
// now save your image to your $path
But i really can't say your behaviour has something to do with that... Without error messages, we can only guess.

create a folder in a grandparent dir

I want to create a dir (named with a varible Utilities._Name)located two levels from the exe file,
My exe file is in C:\SGEA\SGEA\bin
How can I do it so I get C:\SGEA\theNewDir without using full path, just relative paths?
If Not System.IO.Directory.Exists(Utilities._Name) Then
MessageBox.Show("There is already a dir named: " & Utilities._Name, "SGEA", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If you have the path to the exe file, you can use the System.IO.Path Class to navigate easily:
Dim folder = Path.GetDirectoryName(theExeFile)
Dim grandparent = Path.GetDirectoryName(Path.GetDirectoryName(folder)) ' Up two directories
Dim newFolder = Path.Combine(grandparent, "theNewDir") ' Use this to create the new folder name cleanly
Utilities._Name = newFolder

Magento trying to create CSV inside a directory throwing FATAL error Fatal error: Class 'Mage_Helper_Data' not found

I have a script that creates a file and currently puts it inside media folder, but I'd like to have it inside media/files so here is my code
$filePath = Mage::getBaseDir('media') . DS .'files'. 'mycsvfile.csv';
$fileName = 'mycsvfile.csv';
$mageCsv = new Varien_File_Csv();
$mageCsv->saveData($filePath, $ordersRow);
->setRedirect(Mage::helper('adminhtml')->getUrl('mycsvfiles/adminhtml_download/index/', array('file' => $fileName )));
I don't see any errors in your code - aside from
$filePath = Mage::getBaseDir('media') . DS .'files'. 'mycsvfile.csv';
should probably be
$filePath = Mage::getBaseDir('media') . DS .'files'. DS . 'mycsvfile.csv';
since files is a directory. The error you see is probably thrown somewhere else. Try to check your etc section .xml files - the directives translate="label" module="modulename" where modulename is a helper alias. I've had a couple of such errors the other day.