Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > Server-Side Scripting

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
Old 03-07-2006, 03:55 AM   #1
hungboy
Registered User
 
Join Date: Mar 2006
Posts: 13
Default can't upload file from flash and save to mysql database using php


Hi, all!
I have a project to use flash upload file and save it to the mysql database using PHP. But it can't work! It's a multi-upload. If I just save the file to a directory, it's success. But if I save the file data to a database, it doesn't work!
And I have a html version of upload which works correctly. I post the html version and flash version upload code here, hope someone can help me to find out the difference between them.
html version:
Code:
$file = $_FILES;
$file_binary =addslashes(fread(fopen($file['tmp_name'], "r"), filesize($file['tmp_name'])));
$file_name = addslashes($file['name']);
$file_type = $file['type'];
$file_size = intval($file['size']);

//log upload
$thehost = $_SERVER['REMOTE_HOST'];
$theip = $_SERVER['REMOTE_ADDR'];
$theua = $_SERVER['HTTP_USER_AGENT'];
$thetime = time();

$sql = 'INSERT INTO upload_log ('
	.'user_id,user_ip,user_host,user_ua,file_name,file_size,file_type'
	.') VALUES ('
	."'$user_id','$theip','$thehost','$theua','$file_name','$file_size','$file_type'"
	.')';
db_query($sql);
flash version:
Code:
$_FILES_binary =addslashes(fread(fopen($_FILES['Filedata']['tmp_name'], "r"), filesize($_FILES['Filedata']['tmp_name'])));
$_FILES_name = addslashes($_FILES['Filedata']['name']);
$_FILES_type = $_FILES['Filedata']['type'];
$_FILES_size = intval($_FILES['Filedata']['size']);

//log upload
$thehost = $_SERVER['REMOTE_HOST'];
$theip = $_SERVER['REMOTE_ADDR'];
$theua = $_SERVER['HTTP_USER_AGENT'];
$thetime = time();

$sql = 'INSERT INTO upload_log ('
	.'user_id,user_ip,user_host,user_ua,file_name,file_size,file_type'
	.') VALUES ('
	."'$user_id','$theip','$thehost','$theua','$_FILES_name','$_FILES_size','$_FILES_type'"
	.')';
db_query($sql);
Any helps would be very appreciated!
hungboy is offline   Reply With Quote
Old 02-17-2008, 01:23 AM   #2
cordeis
Registered User
 
Join Date: Feb 2008
Posts: 2
Default Cant upload from flash to mysql - very similar problem

Hi all,

im quite competent with programming and such but i have a problem that is becoming increasingly frustrating for me...BIG TIME!!

1. actionscript 2.0, php 4.? and mysql 5.0??
2. Using at the moment (for testing) localhost apache 2.0, and the above (1) applications.

THE PROBLEM!

I can upload a file from flash (with fileReference class) to the fileserver (to a created '/images' folder). However, I want to upload to the blob type of a mysql server database rather than the fileserver storage way of doing things, but when i try to upload to a blob type i cant upload!!!! ive tried numerous ways with no luck. I cant find a tutorial that takes a file uploaded from a flash end user application and store it in a mysql database!! only storing it in a folder instead. I require it to store in the mysql database however but i just cant seem to make this happen.

could please someone direct these thread to correct place if it isnt... could someone please direct me to an appropriate tutorial or could they just explain how my problem could be solved. PLEASE!!! im at wits end!!!

to clarify: im using fileReference to upload from flash, to php (MOVE_FILE - helps to send it to a folder on the server) i want to post the fileReference directly to the mysql instead or alternatively,

2) take the file that is uploaded to the folder, read it with PHP, store it in mysql then delete from folder, although this could cause slower processing times for the end user as more computations are required!

The flash application is ultimately a photo album where the user can upload to the database and then retrieve those images later...so if i going to have trouble retrieving images from the blob please do also give me a heads up now!

thank you very much, sorry for the long post!

Last edited by cordeis; 02-17-2008 at 01:24 AM. Reason: title
cordeis is offline   Reply With Quote
Old 02-17-2008, 11:21 PM   #3
cordeis
Registered User
 
Join Date: Feb 2008
Posts: 2
Default please help, flash upload to mysql, blob type.

Come on guys...is there not anybody that can help with this issue..

need help with uploading with fileReference class .upload() method to a mysql database blob type field using php.

Im using apache 2.0, mysql 5, php 4 and flash 9 but coding mainly in actionscript 2.0. Tutorials do not seem to help and there is no documentation for at least i can not find about uploading files from flash to mysql using php. Im really struggling with this, but i am a competent programmer with some level of skills in all of the mentioned applications. At the moment, i am uploading to a file server and will soon implement it so that the filepath is stored in the mysql as a varchar. i do not want this however, rather wanting to upload to the mysql as a blob. thank you in advance..please help!
cordeis is offline   Reply With Quote
Old 03-14-2008, 02:44 PM   #4
micros
Registered User
 
Join Date: Mar 2008
Posts: 3
Default

Finally I found someone trying the same thing as me. Well, almost the same, because I want to save a ByteArray with image data over an AMFPHP connection into a MySQL database.
I've written a Drupal service, but I'm not all the way there yet. If you have any progress, let me know. I'll do the same, and maybe we can figure this one out together.
micros is offline   Reply With Quote
Old 03-18-2008, 11:28 AM   #5
micros
Registered User
 
Join Date: Mar 2008
Posts: 3
Default

Quote:
Originally Posted by cordeis View Post
Come on guys...is there not anybody that can help with this issue..

need help with uploading with fileReference class .upload() method to a mysql database blob type field using php.

Im using apache 2.0, mysql 5, php 4 and flash 9 but coding mainly in actionscript 2.0. Tutorials do not seem to help and there is no documentation for at least i can not find about uploading files from flash to mysql using php. Im really struggling with this, but i am a competent programmer with some level of skills in all of the mentioned applications. At the moment, i am uploading to a file server and will soon implement it so that the filepath is stored in the mysql as a varchar. i do not want this however, rather wanting to upload to the mysql as a blob. thank you in advance..please help!
We managed to save a ByteArray from Flash over AMFPHP as a blob into a MySQL database. The code is in a Drupal service. let me know if you'd like to see how this is done.
(Our problem now is retreiving it, since we get 'type coercion failed' errors.)
micros is offline   Reply With Quote
Old 04-21-2008, 10:19 PM   #6
bcbirk100
Professional Life Coach
 
bcbirk100's Avatar
 
Join Date: Feb 2007
Posts: 70
Send a message via AIM to bcbirk100
Default

how did you manage to save the byteArray to Mysql? I'm not having any luck getting it to work.
__________________
-You shouldn't take life too seriously. You'll never get out alive
bcbirk100 is offline   Reply With Quote
Old 04-21-2008, 10:31 PM   #7
micros
Registered User
 
Join Date: Mar 2008
Posts: 3
Default

Quote:
Originally Posted by bcbirk100 View Post
how did you manage to save the byteArray to Mysql? I'm not having any luck getting it to work.
Our lifesaver was some code by Flepstudio.org. He shows how to PNGEncode using some source from Flex, and send it Base64 encoded. How the backend handles it exactly I'd have to check, but in essence it literally stores the received data. It is also able to send it back to Flash through another remoting function. We integrated this with a Drupal cms.

http://www.flepstudio.org/forum/tuto...ray-class.html
micros is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
one template, many looks? subquark ActionScript 1.0 (and below) 1166 10-29-2013 06:18 PM
[Q] How to Save Text File in Flash??? CyanBlue Other Flash General Questions 7 03-12-2012 09:16 AM
CyanBlue's 5000th Post - Useful Threads List CyanBlue Projectors and CDs 104 02-25-2005 01:13 PM
flash - php - mysql problem fotis3000 Server-Side Scripting 5 07-08-2002 03:24 AM
Php, Javascript, and Flash 5 browser detect and more! Redline01 Server-Side Scripting 2 08-11-2001 01:09 AM


All times are GMT. The time now is 04:16 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.