|
-
Jun 18th, 2008, 02:04 AM
#1
Thread Starter
Addicted Member
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 
-
Jun 18th, 2008, 11:34 AM
#2
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?
-
Jun 18th, 2008, 11:55 PM
#3
Thread Starter
Addicted Member
Re: How convert .php To .aspx
Ya I understood and i got it..
Failing to plan is Planning to fail 
-
Jun 19th, 2008, 12:51 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|