0
Answer

convert php code snippet to ASP.NET MVC 5

kelum p

kelum p

8y
1.1k
1

down votefavorite

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

 
 
$p1 = $p2 = []; if (empty($_FILES['id']['name'])) {     
echo '{}'; return; } 
for ($i = 0; $i < count($_FILES['id']['name']); $i++) {     
$j = $i + 1;     $key = '<code to parse your image key>';     
$url = '<your server action to delete the file>';     
$p1[$i] = "<img style='height:160px' src='http://path.to.uploaded.file/{$key}.jpg' class='file-preview-image'>",;     
$p2[$i] = ['caption' => "Animal-{$j}.jpg", 'width' => '120px', 'url' => $url, 'key' => $key]; } 
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.