03-07-2006, 03:55 AM
|
#1
|
|
Registered User
Join Date: Mar 2006
Posts: 13
|
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!
|
|
|
02-17-2008, 01:23 AM
|
#2
|
|
Registered User
Join Date: Feb 2008
Posts: 2
|
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
|
|
|
02-17-2008, 11:21 PM
|
#3
|
|
Registered User
Join Date: Feb 2008
Posts: 2
|
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!
|
|
|
03-14-2008, 02:44 PM
|
#4
|
|
Registered User
Join Date: Mar 2008
Posts: 3
|
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.
|
|
|
03-18-2008, 11:28 AM
|
#5
|
|
Registered User
Join Date: Mar 2008
Posts: 3
|
Quote:
Originally Posted by cordeis
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.)
|
|
|
04-21-2008, 10:19 PM
|
#6
|
|
Professional Life Coach
Join Date: Feb 2007
Posts: 70
|
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
|
|
|
04-21-2008, 10:31 PM
|
#7
|
|
Registered User
Join Date: Mar 2008
Posts: 3
|
Quote:
Originally Posted by bcbirk100
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
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 05:28 AM.
///
|
|