Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-28-2005, 03:57 PM   #1
Brandon Rohde
Registered User
 
Join Date: Nov 2005
Posts: 24
Question Upload file from local PC to Server

Hello,

I have written a small flash application that will be run on a local machine. The purpose of the application is to constantly upload an XML file on a set interval. The XML file is rewritten by a third party software program. I am using flash as the upload method because of its light weight, multi-platform support, and that users can upload files to my server without the need for an ftp account.

Anyways, the XML uploads are working great. I would like to add an option to upload other files however, such as txt, html, and pdf. I have the script written already to detect when new files are written, and then it calls a function to upload the file. The problem I am having however is uploading the file. The best way I can think is to load the file into a string and send it to my PHP script to write to a file, much like the XML() function works. Is there something that will do this? I have looked into the new flash.net.FileResource() function, but that seems to require a user to select a file using a browse button. Is there a way I can hardcode the file that will be uploaded?

In short, I have all the dirty work done, I just need a way to send a file from a local machine to a php script so it can be written to a file on the server. Any help is greatly appreciated!
Brandon Rohde is offline   Reply With Quote
Old 11-28-2005, 11:57 PM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

PHP Code:
<?php


    $uploaddir 
getcwd() .'/secure/';
    
$uploadfile $uploaddir basename($_FILES['userfile']['name']);

    echo 
'<pre>';
    if (
$_FILES['userfile']['tmp_name']) {
    
$ok move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile);
        if (
$ok) {
            echo 
"File uploaded and moved\n";
        } else {
              echo 
"File upload but can NOT be moved\n";
        }
    } else {
           echo 
"Possible file upload attack!\n";
    }

?>
Quote:
Is it possible to hardcode a file to be uploaded so the user does not need to click browse to select a file?
Um.....probably not. I believe that would be considered hacking.
ActionScript Code:
var file_to_upload:String = "user_tax_papers.doc" if (file_to_upload) {    trace("Boy, hacking is so easy nowadays. Think i will go shopping"); }
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

Last edited by Flash Gordon; 11-29-2005 at 12:01 AM.
Flash Gordon is offline   Reply With Quote
Old 12-01-2005, 03:00 PM   #3
Brandon Rohde
Registered User
 
Join Date: Nov 2005
Posts: 24
Default

ok, thanks. I figured it would be a security issue, but I wasnt sure if the user could click a button once to authorize a file to be auto-uploaded every X seconds or something to that nature.
Brandon Rohde is offline   Reply With Quote
Old 12-01-2005, 03:11 PM   #4
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

So you limit the file extensions that can be uploaded...security issue solved. Also, the directory you upload them to, change the settings so no files can be executed there....simple..learned that from the ASP 101 days.
__________________
Color Wars | (kul′ər wrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota 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
upload file via broswer, file size limit help? Paul Ferrie Server-Side Scripting 19 04-28-2005 04:18 PM
allow your user to upload their own .swf file to your web server antonyx ActionScript 2.0 4 04-06-2005 06:21 PM
upload file problems Vman Server-Side Scripting 4 01-20-2005 11:47 AM
Problem with loading a file on server bionicsamir ActionScript 1.0 (and below) 6 05-21-2003 09:01 AM
To CyanBleu (Loadvars from server to local). u-lounge Server-Side Scripting 0 04-21-2003 07:09 PM


All times are GMT. The time now is 06:30 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.