Jump to content

Movie File not uploading via submission form


davegfx

Recommended Posts

Hi

 

First post here and am not a programmer so be gentle.  I'm not quite sure whether this is a flash problem, a server issue, or a php coding thing.

 

My site is flash based, but utilizes several php files.  The problem i'm having is with a submission form in which the user uploads several files - an image(x2), a document(x2), and a movie.  When the user uploads them, these files are places in an automatically generated tracking folder on the server. 

 

Now, the images and documents all upload and get places in the folder perfectly.  The movie file seems to upload normally - however, when i check the folder, the movie is not in there.  One interesting thing though is that when i tested with a very small avi (like 150 bytes or something) it was fine.

 

Does anyone have any ideas?

 

 

This is the php script:

 

<?php

 

$subdir=$HTTP_GET_VARS['fid'];

 

if(!is_dir("uploadx/".$subdir)){

mkdir("uploadx/".$subdir, 0777);

}

 

if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {

$uploadDirectory = "uploadx/".$subdir."/";

$uploadFile = $uploadDirectory. basename($_FILES['Filedata']['name']);

copy($_FILES['Filedata']['tmp_name'], $uploadFile);

}

 

?>

 

And this is the flash script for the upload:

 

fileStatus = 0;

bar._xscale = 0;

status_txt.text = "Select a file";

//import the FileReference Object

import flash.net.FileReference;

//create a new FileReference object

var fileRef:FileReference = new FileReference();

//create a listener object for FileReference events

var fileRefListener:Object = new Object();

//apply object listener to the file reference object

// setting files to be browsed

if (paramType == 1) {

fileDescription = "Photographs - Jpg & Png only";

fileExtension = "*.jpg; *.jpeg; *.png";

} else if (paramType == 2) {

fileDescription = "Videos - Mov & Avi only";

fileExtension = "*.avi; *.mov";

} else if (paramType == 3) {

fileDescription = "Documents - Word & Pdf only";

fileExtension = "*.doc; *.docx; *.pdf";

}

//===================== FILEREFERENCE EVENT HANDLER =====================//                                       

//When user selects a file from the file-browsing dialog box,

//the onSelect() method is called, and passed a reference to the FileReference object

fileRefListener.onSelect = function(fileRef:FileReference):Void  {

status_txt.text = "File Size: "+fileRef.size+" bytes"+'\n';

status_txt.text = "File Type: "+fileRef.type+'\n';

status_txt.text = "File Name: "+fileRef.name+'\n';

status_txt.text = fileRef.name;

file_mem = ""+fileRef.name+"";

fileStatus = 1;

};

//When user dismiss the file-browsing dialog box,

//the onCancel() method is called, and passed a reference to the FileReference object

fileRefListener.onCancel = function(fileRef:FileReference):Void  {

status_txt.text = "Cancelled";

fileStatus = 0;

};

//When the file upload/download process started,

//the onOpen() method is called, and passed a reference to the FileReference object

fileRefListener.onOpen = function(fileRef:FileReference):Void  {

// status_txt.text = "Uploading "+fileRef.name;

bar._xscale = 100;

};

//The onProgress() method is called periodically during the file upload operation

fileRefListener.onProgress = function(fileRef:FileReference, bytesLoaded:Number, bytesTotal:Number):Void  {

//setting the status bar function

// status_txt.text = "Uploaded "+int(100*bytesLoaded/bytesTotal)+"%";

status_txt.text = fileRef.name;

for (n=0; n<rand; n++) {

rand = random(4);

status_txt.text += ".";

}

bar._xscale = 100-(100*bytesLoaded/bytesTotal);

};

//When the file upload/download operation is successfully complete,

//the onComplete() method is called, and passed a reference to the FileReference object

fileRefListener.onComplete = function(fileRef:FileReference):Void  {

status_txt.text = fileRef.name;

gotoAndStop(3);

if (paramType == 1) {

imagePane.contentPath = "./uploadx/"+_root.postman.fid+"/"+fileRef.name;

}

bar._xscale = 0;

fileStatus = 3;

_parent.proceed();

};

//********************************* ERROR EVENT HANDLING *********************************//

//This method will be called if and only if an upload fails because of an HTTP error

fileRefListener.onHTTPError = function(fileRef:FileReference, error:Number) {

status_txt.text = "Upload failed";

fileStatus = 2;

bar._xscale = 0;

_parent.proceed;

};

//This method will be called if and only if a file input/output error occur

fileRefListener.onIOError = function(fileRef:FileReference) {

status_txt.text = "Upload failed";

fileStatus = 2;

bar._xscale = 0;

_parent.proceed;

};

//This method will be called if and only if an upload fails because of a security error

//9 out of 10 time this error occus is because of the user Flash8 player security settings

fileRefListener.onSecurityError = function(fileRef:FileReference, errorString:String) {

status_txt.text = "Upload failed";

fileStatus = 2;

bar._xscale = 0;

_parent.proceed;

};

//****************************************************************************************//

//attach Listener to the FileReference Object

fileRef.addListener(fileRefListener);

//button event for the browse button

browseButn.onRelease = function() {

//The browse function is the key, coz it displays a file-browsing dialog box

//in which the user can select a local file to upload

fileRef.browse([{description:fileDescription, extension:fileExtension}]);

};

//event for the upload

function startUpload() {

if (fileStatus == 3) {

_parent.proceed();

} else if (fileStatus == 1) {

fileRef.upload("newload.php?&fid="+_root.postman.fid+"&");

} else {

status_txt.text = "Not selected";

_parent.proceed();

}

}

Link to comment
Share on other sites

$HTTP_GET_VARS was depreciated almost 8 years ago, it has been turned off by default in php5, and it has been completely removed in php6. Use $_GET

 

The php code is not checking for any of the possible upload errors - http://www.php.net/manual/en/features.file-upload.errors.php so it will be a little hard for anyone to tell you exactly why your code is not working for the movie files.

 

I'll guess that if you added some error checking logic to your code that you would get an uploaded error value of 1, meaning that the file exceeded the upload_max_filesize setting.

Link to comment
Share on other sites

Hi

 

Thank you very much for your reply!  I did some more investigating and it seems to be definitely be a file size setting. 

 

If i upload a movie under 2MB then everything is fine.  If i try anything above 2mb then it doesn't work.  Coincidentally, the document and image uploads are limited to files below 2mb, although I am unsure of where this is located in the code. 

 

Any idea?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.