Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's some actionscript to upload a single photo - adapt it for your needs. The PHP follows.</p> <pre><code>private function onUploadCompleteData ( event : DataEvent ) : void { var resultXML : XML = new XML( event.data ); if ( resultXML == null ) return; var storednameString : String = resultXML..filename[0]; } private function uploadPicture() : void { uploadFileReference = new FileReference(); uploadFileReference.addEventListener( Event.SELECT, onSelectFile, false, 0, true ); uploadFileReference.addEventListener( DataEvent.UPLOAD_COMPLETE_DATA, onUploadCompleteData, false, 0, true ); uploadFileReference.addEventListener( IOErrorEvent.IO_ERROR, onUploadError, false, 0, true ); uploadFileReference.browse(); } private function onUploadError( event : IOErrorEvent ) : void { Alert.show( "Unable to upload picture.", "Photo" ); } private function onSelectFile( event : Event ) : void { try { // this is where you pass stuff to PHP - file info, storage info var urlParams : URLVariables = new URLVariables(); urlParams.some_info = some_info; urlParams.sessionId = phpsessionId; uploadURL = new URLRequest(); // this is where you'd put the URL for your server uploadURL.url = serverpathString + "/php/uploadPhoto.php"; uploadURL.method = URLRequestMethod.POST; uploadURL.data = urlParams; uploadFileReference.upload( uploadURL ); } catch ( error : Error ) { Alert.show( "Unable to upload file.", "Photo" ); } } &lt;mx:Form height="100%"&gt; &lt;mx:Button label="Select" click="uploadPicture()"/&gt; &lt;/mx:Form&gt; </code></pre> <p>PHP to upload a file:</p> <pre><code>&lt;?php // there is a bug in the flex upload code where the session id isn't being sent. This is a patch for that. session_id( $_REQUEST[ 'sessionId' ] ); $some_info = $_REQUEST[ 'some_info' ] ); session_start(); $maxSize = 1024 * 1000; // 1 Mb if ( $_FILES[ 'Filedata' ][ 'size' ] &gt; $maxSize ) { echo "&lt;ret/&gt;"; return; } $filename_inbound = $_FILES[ 'Filedata' ][ 'tmp_name' ]; $utc = microtime( true ); move_uploaded_file( $filename_inbound, "/data/pictures/$filename" ); // if you change the stored filename - here is where it gets returned to actionscript // return success / fail the same way echo "&lt;ret&gt;&lt;filename&gt;$filename&lt;/filename&gt;&lt;/ret&gt;"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload