Is there a way to move uploaded file and name it with german characters?
I have a form where user inputs his name and surname and adds a file.
File is uploaded correctly and all input fields are saved in mysql database.
public function store(Request $request)
{
$file = $request->file('file');
$file_name = $request->input('name_surname') . '_' . $request->input('month') . '.' . $file->getClientOriginalExtension();
$request->file('file')->move('uploads', $file_name);
$this->report->create(array('name_surname' => $request->input('name_surname'),
'file_name' => $file_name,
'ini_file_name' => $file->getClientOriginalName(),
'month' => $request->input('month'),
'sum' => $request->input('sum')));
return redirect('/');
}
When I open my 'uploads' folder, file name looks like this:
Günter Baumgärtner_Februar 2015.pdf
dd($file_name); shows this:
"Günter Baumgärtner_Februar 2015.pdf"
MySQL record looks like this:
id | name_surname | month | sum | file_name | ini_file_name
39 | Günter Baumgärtner | Februar 2015 | 200 | Günter Baumgärtner_Februar 2015.pdf | report-11-02-2015_01-36.pdf
Looks like a problem with your system encoding. Is your machine running Linux?
If yes, check your server LANG enviromental variable: at command prompt type locale and look at a line starting with LANG=. If it is LANG=en_US.UTF-8 (or any other value ending with .UTF-8) then renaming/creating files with german characters should work. In my environment (LANG=pl_PL.UTF-8) it works, my Laravel app created a file named Günter_Baumgärtner.csv.
If your LANG is set to non-UTF-8 value, then should change it, but the way how to do it depends on your Linux distribution.
Related
I get Request body data from excel file.
I have already covert excel to csv format.
I have kind of able to find a solution but it is not working 100% as jsonbody format in not fetching data correctly is shows forward slash in csv import data from runner collections.
Request Body
{{jsonBody}}
Set Global variables jsonBody
Run collection select data file as csv file as per screenshot request body shows with forward slash.
After running the collection I'm getting body incorrect version with forward slash.
This below screenshot show correct version on csv data I require to remove forward slash from csv data
I had similar issue with postman and realized my problem was more of a syntax issue.
Lets say your cvs file has the following columns:
userId | mid | platform | type | ...etc
row1 94J4J | 209444894 | NORTH | PT | ...
row2 324JE | 934421903 | SOUTH | MB | ...
row3 966RT | 158739394 | EAST | PT | ...
This is how you want your json request body to look like:
{
"userId" : "{{userId}}",
"mids":[{
"mid":"{{mid}}",
"platform":"{{platform}}"
}],
"type":["{{type}}"],
.. etc
}
Make sure your colums names match the varibales {{variableName}}
The data coming from CSV is already in a stringified format so you don't need to do anything in pre-request.
example:
let csv be
| jsonBody |
| {"name":"user"}|
Now in postman request just use:
{{jsonBody}}
as {{column_name}} will be considered as data varaible so , in your case {{jsonBody}}
csv:
make sure you save this as csv file :
Now in request use :
output:
if you want to add the json body as value of another then just use :
Output:
I am using a powerCLI script to disable vNICs on VMs and to export the status of vNICs. I am trying to export ConnectionState.
I am using Get-VM $vm | Get-NetworkAdapter | Select Name, ConnectionState to extract output to a CSV file.
The CSV generated has vNIC name and ConnectionState but I wish to add VM name for respective VMs. I tried various options but no luck.
There should be an additional property available as part of the output from Get-NetworkAdapter called "Parent". This property should be the name of the VM.
Your command should be updated to look like:
Get-VM $vm | Get-NetworkAdapter | Select-Object Parent, Name, ConnectionState
How can I read a file from a specific byte position in Robot Framework?
Let's say I have a process running for a long time writing a long log file. I want to get the current file size, then I execute something that affects the behaviour of the process and I wait until some message appears in the log file. I want to read only the portion of the file starting from the previous file size.
I am new to Robot Framework. I think this is a very common scenario, but I haven't found how to do it.
There are no built-in keywords to do this, but writing one in python is pretty simple.
For example, create a file named "readmore.py" with the following:
from robot.libraries.BuiltIn import BuiltIn
class readmore(object):
ROBOT_LIBRARY_SCOPE = "TEST SUITE"
def __init__(self):
self.fp = {}
def read_more(self, path):
# if we don't already know about this file,
# set the file pointer to zero
if path not in self.fp:
BuiltIn().log("setting fp to zero", "DEBUG")
self.fp[path] = 0
# open the file, move the pointer to the stored
# position, read the file, and reset the pointer
with open(path) as f:
BuiltIn().log("seeking to %s" % self.fp[path], "DEBUG")
f.seek(self.fp[path])
data = f.read()
self.fp[path] = f.tell()
BuiltIn().log("resetting fp to %s" % self.fp[path], "DEBUG")
return data
You can then use it like this:
*** Settings ***
| Library | readmore.py
| Library | OperatingSystem
*** test cases ***
| Example of "tail-like" reading of a file
| | # read the current contents of the file
| | ${original}= | read more | /tmp/junk.txt
| | # do something to add more data to the file
| | Append to file | /tmp/junk.txt | this is new content\n
| | # read the new data
| | ${new}= | Read more | /tmp/junk.txt
| | Should be equal | ${new.strip()} | this is new content
I am using cucumber feature file to execute or write my test cases. Issue is that I am using data table as :
| abc | 1234567890 |
| defg | New Activation – Monthly (Credit in store) |
Now issue is this that console is throwing an error that :
Cannot locate element with text: New Activation ? Monthly (Credit in store).
I am not able to understand why ? is being displayed instead of "–" .
I just wanted to know how to configure FCKEditor to upload files and images to the server where the website is hosted.
The relevant part for it's config file(i think) looks like this:
FCKConfig.LinkUpload = true ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension ;
FCKConfig.LinkUploadAllowedExtensions = ".(7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip)$" ; // empty for all
FCKConfig.LinkUploadDeniedExtensions = "" ; // empty for no one
FCKConfig.ImageUpload = true ;
FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ;
FCKConfig.ImageUploadAllowedExtensions = ".(jpg|gif|jpeg|png|bmp)$" ; // empty for all
FCKConfig.ImageUploadDeniedExtensions = "" ; // empty for no one
Could it be a folder permission problem? Is this part of the config.js alright?
You don't state what language you are using. The fileupload functionality in FCKeditor has ASP, .NET, Coldfusion and PHP uploaders, amongst others. It would help if you said what server (IIS/Linux?) and serverside language you are using.
With limited information its a long shot but there's settings in fckconfig.js for configuring your file browser (around line 276) Make sure you have the right language selected:
var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py
You'll also have to set write permissions on the folder structure you are uploading to (which might be the cause of the "invalid request" error, but process to edit file permissions is different depending if you are using windows or linux.
Its not well documented, but its also possible to debug the file manager settings by going to the following URLs in a browser:
/fckeditor/editor/filemanager/connectors/test.html
and
/fckeditor/editor/filemanager/connectors/uploadtest.html
The upload test scripts are very useful and can help diagnose many problems - you can see errors easier for a start. Give them a try and you should have a better idea what the problem is.
It's solved, thanks anyway. I just had to add the "Files" type to some variable at the config.aspx file. It only had "Images", so that's why I couldn't upload files