Results 1 to 4 of 4

Thread: How convert .php To .aspx

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Thumbs up How convert .php To .aspx

    Hi i have a script.php file for using upload. This is running in php successfully.

    I need to convert this code to .aspx on page load.

    <?php

    $result = array();

    if (isset($_FILES['photoupload']) )
    {
    $file = $_FILES['photoupload']['tmp_name'];
    $error = false;
    $size = false;

    if (!is_uploaded_file($file) || ($_FILES['photoupload']['size'] > 2 * 1024 * 1024) )
    {
    $error = 'Please upload only files smaller than 2Mb!';
    }
    if (!$error && !($size = @getimagesize($file) ) )
    {
    $error = 'Please upload only images, no other files are supported.';
    }
    if (!$error && !in_array($size[2], array(1, 2, 3, 7, 8) ) )
    {
    $error = 'Please upload only images of type JPEG.';
    }
    if (!$error && ($size[0] < 25) || ($size[1] < 25))
    {
    $error = 'Please upload an image bigger than 25px.';
    }

    $addr = gethostbyaddr($_SERVER['REMOTE_ADDR']);

    $log = fopen('script.log', 'a');
    fputs($log, ($error ? 'FAILED' : 'SUCCESS') . ' - ' . preg_replace('/^[^.]+/', '***', $addr) . ": {$_FILES['photoupload']['name']} - {$_FILES['photoupload']['size']} byte\n" );
    fclose($log);

    if ($error)
    {
    $result['result'] = 'failed';
    $result['error'] = $error;
    }
    else
    {
    $result['result'] = 'success';
    $result['size'] = "Uploaded an image ({$size['mime']}) with {$size[0]}px/{$size[1]}px.";
    }

    }
    else
    {
    $result['result'] = 'error';
    $result['error'] = 'Missing file or internal error!';
    }

    if (!headers_sent() )
    {
    header('Content-type: application/json');
    }

    echo json_encode($result);

    ?>

    The above code need to be convert to .aspx in page load .

    I hope ur reply. Thanks
    Failing to plan is Planning to fail

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How convert .php To .aspx

    You can't simply find a formula to convert a PHP page and its functionality into another language or technology.

    You first need to understand what the page is doing and then use the controls and tools provided in ASP.NET to accomplish the same thing.

    This page currently seems to be accepting files uploaded to it, checking the size and filetype before it then... saves it?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: How convert .php To .aspx

    Ya I understood and i got it..
    Failing to plan is Planning to fail

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How convert .php To .aspx

    Add Resolved... Post back if you have more questions as you're doing this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width