Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
Related to this -- https://stackoverflow.com/questions/21487257/a-perl-cgi-script-for-uploading-files -- question, I have another one: can this:
http://www.seaglass.com/file-upload-pl.html
script be modified so that it would accept different input files and save them as different output files, and not just overwrite the single output file?
I'm new to Perl/CGI, so I wouldn't see an obvious answer.
In $basename you already have name of the file. You do not have to write the uploaded file into /tmp/outfile; you can construct the path dynamically, depending on $basename.
Create a directory where you want to place the files. I assume it will still be C:\tmp. Instead of
open(OUTFILE, ">/tmp/outfile")
write
open(OUTFILE, ">/tmp/$basename")
and it should work. Taint is removed from $upfile inside GetBasename(), even before $basename is created. But this is not safe, still. Before giving it to open(), you should remove all unwanted characters from the file name, e.g.
$basename =~ s/[^A-Za-z0-9_.-]//g;
$basename =~ s/^[^A-Za-z0-9]*//;
If $basename is empty now, you have to chose a name other way. Also if file of the same name already exists, you have to choose whether you want to overwrite it or make up a unique name. My current solution just overwrites.
If you want to know more about regular expressions, look at perlre manual page.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
So I am working with an Rmd file which I later convert into and md file using the knitr package. The md file(not mine, just an example) starts with
I am interested in how the text between the hyphens at the top is parsed. I want it to look like a table below,
but instead when I wrap the text with three hyphens in my repos I get what is highlighted in green
I have no idea why or what is different in my repo. What I did notice is that if use the three hyphens wrap without using any code chunks in my md file, then I get the desired table. So, somehow the code chunks like that
\```css
code chunk
\```
mess up the three hyphens wrap being parsed as a table. Any ideas of how to resolve this issue? Thanks.
It's not that github is parsing --- as a table delimiter, it is specifically parsing a yaml metadata block located at the top of the file (which uses --- as it's delimiters) as a table.
See here for the announcement.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My problem is that I want to read a text file from a specific link, but I found it quite difficult.
First, my text file is organized as follows:
h20198988 book, old book, new book
h20887878 computer, machine, new machine,
My task is to find a particular word in the entire text file and return the number corresponding to that word as an output.
I know that I can use regexp or strtok to find a word?
Looking at earlier (and possibly related) questions you posted, it seems like you are simply copying the file from one location to another. You can make life much simpler for yourself by never "knowing" it is an image file at all. If you never convert the file, it will be faster, and when you treat it as a binary file you can just use fread and fwrite for file I/O:
filepath{k}=fullfile(imgpath,T_MODE,keyword,strcat('img_',num2str(count_save),'.jpg');
fin = fopen(fileSource, 'rb');
temp = fread(fileSource);
fclose(fin);
fout = fopen(filepath{k}, 'wb');
fwrite(fout, temp);
fclose(fout);
This does not explain why you are having trouble with imwrite - you haven't explained why it is not working for you. I do worry a little bit about the strange things you are doing with the fullfile function; are you sure the directory you are writing to exists? You might want to do instead:
filedir = fullfile(imgpath,T_MODE,keyword);
… test for existence of fielder
filename = fullfile(filedir, sprintf("img_%03d.jpg', count_save);
The advantage of this is 1) slightly faster (you do most of the concatenation only once), 2) a chance to test for existence of directory before writing to it, and 3) you have better control over the formatting of the name (using %03d means you get 001.jpg, 002.jpg etc - which will keep things in proper order. Otherwise, they show up as (e.g.) 1, 10, 11, 12, 2, 3, 4, 5 because directory listings tend to be lexical (alphabetical). )
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I'm paying high price for not organising my mp3 files on regular basis.
There are three big steps I need to take and without automation they are a nightmare.
1 . Organise folders (so far I moved all mp3 folders to one location):
G:/Music/New Folder/artist/ (1000 files here)
G:/Documents/Music/mp3/ (1000 files here)
G:/New Folder/Music/new/ (1000 files here)
and so on, you got the idea
So, what I'm looking for is a way I can move all the mp3 files from folders/subfolders/ to one G:/Sorted Music folder.
2 . Take the
filename "01 - ABBA - Waterloo", Title: "Waterloo", Artist: "Unknown" and make it
filename "ABBA - Waterloo", Title: "Waterloo", Artist: "ABBA", deleting every other attribute/field at the same time ("Album", "Contributing Artist", "Comments" etc.)
3 . Having mp3 files all in one place, and all in the same format, divide them into folders:
Sorted Music/Artist/ (files here)
Sorted Music/Artist/ (files here)
For points 2 and 3(especially) I downloaded Mp3tag v2.54. However, because of the "01" in the filename, it "misextracts" information from filename to put into tags. And because of "Unknown" for the artist, it won't make the filename right.
Any useful tips will be appreciated.
If your files have a similar name. ANYTHING - BAND - TITLE then this should be no problem. You can use Autoit3 to organize your files and set and get the mp3 tags.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
When executing a C-program, we have to type a '.' token and a '/' token together followed by our program name:
./program
What do each of the these tokens mean? Why do they need to be together to work?
The ./ syntax just refer to the current directory (Actually . is the current directory while / is the path separator). This is needed because the shell will look into folders specified in $PATH environment variable for executables. Since the program is in the current directory which is not inside PATH by default you need to specify the folder you are running it from.
Actually, this has nothing to do with C. This value is simply passed along to the operating system and used to locate a file.
But on Windows, it doesn't appear to have much meaning at all. . is the current directory and the / is simply the path separator between the current directory and program. Since the OS defaults to the current directory, it refers to the same path as just program.
. means current path
.. means parent.
/ means root or path separator. Depends on Unix/Windows/Mac
./ means current path and relates, towards RHS.
./Program means PWD and Program as Directory or Location.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have some zipped plug-ins, when I try to unpack that the unpacking fails. When I looked deep into it I found that the some of the files are exceeding 256 characters, which I guess is not allowed in WINDOWS operating system.
So my question is there any way to find out if any file name inside a particular folder exceeds 256 characters?
I'm using WINDOWS XP operating system.
Thanks in advance!!
Anand
Without having your zip file is a bit harder to find out if the problem is exactly what you said... AFAI remember, 7zip would truncate the long file names, not "not extract" them. But I don't have any zip with long names to test.
I'd try some things:
Open the zip file with 7zip and try to rename the long names, instead of extracting them.
Try to open the zip file with other zip app, like (izarc)[http://www.izarc.org/news.html], and rename the files
If you don't have access to another computer, try to use one of the available online unzippers. For example: http://jcarleemae.wen.ru/extract.html