Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to load images from client side when the swf is hosted on a server without uplaoding it to server?

New Here ,
Nov 23, 2007 Nov 23, 2007
I'm trying to build a online image resize tool.
problem i face are:

1. I build a button that allow user to browse the file. Once file is selected, it doesnt show full path.
2. lets say if it shows fullpath, but i try to load it into a movieclip, and it doesnt work because the swf file is located at the server and not the client's place.
3. as far as i know, flash can only load images which is located in the same server or internet.
4. if i use php, asp, cgi.. it can only allow me to 1st upload the image then resize later, but this is not wat i want.
5. I need to 1st resize then upload later, because if i have 100 and more photos taken from digicam, it's going to be very slow and heavy.

What i have tested:
1. upload "image3.jpg" into the same directory as the "viewer.swf", and it works.
2. do not upload the swf to the server, but run locally from the user's computer and open "image3.jpg" and it works.
3. upload the swf to the server and open "image3.jpg" from the user's computer and IT DOESN"T WORK!

please help me out.

Thanks~!


TOPICS
ActionScript
907
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 25, 2007 Nov 25, 2007
adobe air is in beta 2 release and is free:

http://labs.adobe.com/downloads/air.html
Translate
Community Expert ,
Nov 23, 2007 Nov 23, 2007
you must upload the image to the server, load it into flash (can be done with one step, as far as the user knows), resize it and then save it to the server and/or user's computer.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 23, 2007 Nov 23, 2007
ok, that basically defeats the meaning of my application.

i want to build a flash app hosted on the website.
the app allows user to browse a file and resize it AUTOMATICALLY and then upload (or save it) into the server.

my problem is step 1, "I can't load the image into a movie clip without uploading it to the server".
you can have a look at my codes, its a bit updated from the source code i posted ealier.
http://freelance.zerodevice.net/websitesupportdesk/index.fla

please help me.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 23, 2007 Nov 23, 2007
flash connecting to PHP its posible to all. and use file uploading function. ok
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 23, 2007 Nov 23, 2007
quote:

Originally posted by: finox006
flash connecting to PHP its posible to all. and use file uploading function. ok


yes, i know all about using php to do uploading.

my point is not uploading, my point is more like, how to load images without uploading the image into the server?

i want to load an image directly from a user's computer, then display it into a swf hosted on a server.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 24, 2007 Nov 24, 2007
if you can't upload to a server, you can't use flash to do what you want.

but why not upload to a server?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2007 Nov 24, 2007
because my user has around 500 image needed to be upload to the server and they are all larger than 2048px.
if all needs to be uploaded to the server then resize will take a very very long time and my server bandwidth is also a problem.

well put it this way.
Here's an example scene similar to my problem.
assuming if i coded a flash mp3 player, then i host it up on the server, then the player should allow user to play the mp3 files which is located in the same server, and then it also plays mp3 which is directly loaded from the user's pc without "preuploading" since the mp3 files are like 4MB, and some users are still using 56k modem.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 24, 2007 Nov 24, 2007
then maybe you should be creating a client-side application. check adobe air.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2007 Nov 25, 2007
hmm... nvm heard of it.

will have a look at it.
isit expensive?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 25, 2007 Nov 25, 2007
adobe air is in beta 2 release and is free:

http://labs.adobe.com/downloads/air.html
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2007 Nov 25, 2007
ok.
thanks.

i guess that's the only solution.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 26, 2007 Nov 26, 2007
you're welcome. it's almost certainly not the only solution. but you're not going to accomplish what you stated using flash.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 26, 2007 Nov 26, 2007
use this php code.
for flash php image prosses.
--------------------------------------------------------
flash file
--------------------------------------------------------
import flash.display.BitmapData;
shaF.onPress = function() {
output();
};
function output() {
snap = new BitmapData(mc._width, mc._height);
snap.draw(mc);
var pixels:Array = new Array();
var w:Number = snap.width;
var h:Number = snap.height;
for (var a = 0; a<=w; a++) {
for (var b = 0; b<=h; b++) {
var tmp = snap.getPixel(a, b).toString(16);
pixels.push(tmp);
}
}
var output:LoadVars = new LoadVars();
output.img = pixels.toString();
output.height = h;
output.width = w;
output.send("show.php", "output", "POST");
}
stop();


----------------------------------------------------------------
PHP file (show.php)
--------------------------------------------------------
<?php
$data = explode(",", $_POST['img']);
$width = $_POST['width'];
$height = $_POST['height'];
$image=imagecreatetruecolor( $width ,$height );
$background = imagecolorallocate( $image ,0 , 0 , 0 );
//Copy pixels
$i = 0;
for($x=0; $x<=$width; $x++){
for($y=0; $y<=$height; $y++){
$int = hexdec($data[$i++]);
$color = imagecolorallocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
imagesetpixel ( $image , $x , $y , $color );
}
}
//$font = imageloadfont('arial.ttf');
$font = 'arial.ttf';
// $text_color = imagecolorallocate($image, 233, 14, 91);
$black = imagecolorallocate($image, 0, 0, 0);
//imagestring($image, $font, 5, 5, "A Simple Text String", $text_color);
imagettftext($image, 12, 0, 10, 20, $black, $font, "A Simple Text String");

//Output image and clean
//header("Content-Type: image/png");
imagepng($image,"finoy.png");
imagedestroy( $image );
?>
<html>
<body>
<img src="finoy.png" width="159" height="159" />
</body>
</html>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2007 Nov 27, 2007
LATEST
your response finox, is inappropriate for this thread.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines