kelum p

kelum p

  • NA
  • 2
  • 2.4k

convert php code snippet to ASP.NET MVC 5

Dec 17 2015 2:55 AM
I don't have knowledge about PHP , Curently I'm doing asp.net mvc 5 project in that I want to convert following php code snippet to asp.net mvc which is C# programming language.
 
To do this easily I just did some research and I saw there is tool to do this. which is PHP to ASP.NET Migration Assistant . But its not working at all there for I have to do this manually , really appreciate suggest way to do this
  1. $p1 = $p2 = []; if (emptyempty($_FILES['id']['name'])) {       
  2. echo '{}'return; } for ($i = 0; $i < count($_FILES['id']['name']); $i++) {       
  3. $j = $i + 1;     $key = '<code to parse your image key>';       
  4. $url = '<your server action to delete the file>';       
  5. $p1[$i] = "<img style='height:160px' src='http://path.to.uploaded.file/{$key}.jpg' class='file-preview-image'>",;       
  6. $p2[$i] = ['caption' => "Animal-{$j}.jpg"'width' => '120px''url' => $url'key' => $key]; }   
  7. echo json_encode([ 'initialPreview' => $p1'initialPreviewConfig' => $p2'append' => true ]);  
 
basically above PHP Server code
 
1. processing ajax upload and returns a JSON response.

2. my server action must return a json object containing initialPreview, initialPreviewConfig, & append.