I want to arrange the data as in a text file but its format has been changed when I tried to get the file from a directory and displayed it in an app the problem for me is it has no reference point at the line ending so I don't know how can I explode it Here is the file format:
This is how data should look
and this is how I am getting data:
This is how m getting the data now
one more thing from these lines I want to pick some data to be stored how can I pick data without reference points?
I mean as you see here:
PIDF***HEMP ZONE ULTRA THIN ROLLING PAPERS 1.25" 25CT~
we have * and ~ to explode and get the data in array format but how can we pick data when the data is like that:
B84921501625VSSE ALTO MENT 463405005397BX00090500360078000
"as I want to pick the name "ALTO MENT" 4, "63405005397
how can I pick that data?
Here is what I did till now:
public function read_confirmation(){
$cpath = public_path('confirmations\pending');
$c_allfiles = scandir($cpath);
$c_allfiles = array_diff(scandir($cpath), array('.', '..'));
foreach ($c_allfiles as $fname) {
$file= File::get(public_path('confirmations\pending/'.$fname));
return $file;}
}
How to show uploaded files using multiple upload files?
With data like this
Lets consider you name is in this variable = $uploadedFiles;
$uploadedFiles = ["file1","file2","file3"];
$temp = json_decode($uploadedFiles);
foreach($temp as $name) {
echo $name;
}
It will print your file name 1 by 1
It just names you need the files also
but if you want to store only that names then you can do it by taking a loop for that variable array
if it is not an array then convert to array using json_decode(array)
This is my controller function where i am running a loop to create multiple document pdf
and merge into one.
public function tick_pdf(){
$tt='';
$name="iftekhar";
$title="Event Football";
$num=4;
for($i=0;$i<4;$i++){
$this->pdfHeader($row->EventId);
$this->pdf->fontpath = 'font/';
//$this->pdf->AddPage();
$this->pdf->Ln(10);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Name",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$name,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Title",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$title,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Number",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$num,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Date",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$date,0,1);
$tt.=$this->pdf->Output('', 'S');
}
echo $tt;
}
but I am gettiin an error in browser
"Undefined index: data
Filename: libraries/fpdf.php
Line Number: 1659" I am using fpdf for generating pdf
If you need to create multiple PDF documents you will need several class instances. Actually you're working with only one instance.
Also it is not possible to concatenate a PDF document by simply concatenating their bytes ($tt .= ...). Generally it is not possible to send multiple PDF documents to the client in a single request.
If you want to create multiple pages, just remove the comment before AddPage(), delete the variable $tt and move the Output() call outside of the loop.
Just as the title says, I want to know how to access the data from the temporary file stored by Django, when a file is uploaded, inside a view.
I want to read the data uploaded values so I can make a progress bar. My methodology is to perform a jquery getJSON request:
function update_progress_info() {
$progress.show();
$.getJSON(progress_url, function(data, status){
if (data) {
var progress = parseInt(data.uploaded) / parseInt(data.length);
var width = $progress.find('.progress-container').width()
var progress_width = width * progress;
$progress.find('.progress-bar').width(progress_width);
$progress.find('.progress-info').text('uploading ' + parseInt(progress*100) + '%');
}
window.setTimeout(update_progress_info, freq);
});
};
where progress_url is the view I have that handles the uploaded file data:
# views.py (I don't know what to do here):
def upload_progress(request):
for line in UploadedFile.temporary_file_path
response = (line)
return response
Django handles uploaded files with UploadHandler defined in settings.py with this name FILE_UPLOAD_HANDLERS that defaults to this tuple:
FILE_UPLOAD_HANDLERS =
("django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",)
The behavior with file uploads is that if the file is less than 2.5 mg then it will be kept on memory, hence, they will not be written in disk as temporary files.
If the file weights more, it will be written in chunks in the FILE_UPLOAD_TEMP_DIR in the settings.py. That's the file you'll have to query to know how many bytes have been uploaded.
You can access the uploaded/uploading files through your request variables in views like this: file = requests.FILES['file'] . There, file variable will have the type UploadedFile which contains a method temporary_file_path with the address of the file in the disk being uploaded. (Note: only files larger than 2.5 mg will have this methods) so there you may get the size of the file being uploaded.
Another way to do this is create your own UploadHandler like a ProgressBarUploadHandler and add it to your file upload handlers. This is the way the docs recommend it. Here are some snippets and tutorials for doing it.
If you need any more info the doc is really well documented.
I hope you find this helpful. Good luck.
I have a variable in the MATLAB workspace and I want to pass this variable to a function in my GUI.
How do I achieve this task?
You can use the function EVALIN in your GUI to get the value of a variable from the base workspace. The following example extracts the value of the variable A in the base workspace and places that value in the local variable B:
B = evalin('base','A');
You could, for example, have an editable text box in your GUI that allows the user to enter the name of a variable to import from the base workspace. One of your GUI functions could then read the string from the editable text box and attempt to fetch that variable from the base workspace to use in some computation:
varName = get(hEditText,'String'); %# Get the string value from the uicontrol
%# object with handle hEditText
try %# Make an attempt to...
varValue = evalin('base',varName); %# get the value from the base workspace
catch exception %# Catch the exception if the above fails
error(['Variable ''' varName ... %# Throw an error
''' doesn''t exist in workspace.']);
end
You can use SETAPPDATA (in the main workpsace) and GETAPPDATA (in GUI) functions.
If you variable is someMatrix
setappdata(0,'someMatrix',someMatrix) % in the main workspace
someMatrix = getappdata(0,'someMatrix') % in GUI