Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:30:25+00:00 2026-05-26T21:30:25+00:00

Alright, so heres my problem, i need my user to be able to upload

  • 0

Alright, so heres my problem, i need my user to be able to upload a video, the video can be any size, so i have written a php script to deal with placing the file in the correct place..Here is my code:

-(IBAction)upload:(id)sender{
[self post:webdata];
}

webdata is the video data, here is the code where i set that up:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
[self dismissModalViewControllerAnimated:YES];
//assign the mediatype to a string 
//check the media type string so we can determine if its a video
    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    webData = [[NSData alloc]init];
    webData = [NSData dataWithContentsOfURL:videoURL];
    //[self post:webData];
    video = 1;
    upload.hidden = NO;

    ImagesCopy = [[NSMutableArray alloc]initWithObjects:@"1", nil];
[tableview reloadData];


 }

Okay so now i have the webdata all done, now i need to upload the data by calling [self post:webdata as posted above

- (void)post:(NSData *)fileData

{

NSMutableArray *array = [[NSMutableArray alloc]initWithContentsOfFile:[self saveUserLogin]];

int test;
NSString *string = [array objectAtIndex:3];
test = [string intValue];
test++;
NSData *videoData = fileData;
NSString *urlString = [[NSString alloc]initWithFormat:@"http://www.site.com/members/uploadMovie.php?&username=%@", [array objectAtIndex:0]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:100000000000];
[request setHTTPMethod:@"POST"];
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSString *postName = [[NSString alloc]initWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"vid%i.mov\"\r\n", test];
[body appendData:[[NSString stringWithString:postName] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:videoData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];


//NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:YES];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if (connection) {
    responceData = [NSMutableData data];

}
else{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Well something went wrong, make sure you have a valid internet connection and try again" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
}
//  NSLog(@"%@", returnString);

NSArray *values = [[NSArray alloc] initWithObjects: [array objectAtIndex:0],[array objectAtIndex:1], [array objectAtIndex:2], [NSString stringWithFormat:@"%i", test], nil];
[values writeToFile:[self saveUserLogin] atomically:YES];

}

Okay, so now i need to call in some methods:

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responceData appendData:data];

}

    -(void)connection:(NSURLConnection *)connection didSendBodyData (NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten 
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{

if([connecting isAnimating]){
    [connecting stopAnimating];
[connectingImage removeFromSuperview];
[connecting removeFromSuperview];
}
float progress = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
float total = [[NSNumber numberWithInteger: totalBytesExpectedToWrite] floatValue];
progressForUpload.progress = progress/total;

 }

 - (void) connectionDidFinishLoading:(NSURLConnection *)connection {

NSString* responseString = [[NSString alloc] initWithData:responceData     encoding:NSUTF8StringEncoding];
NSLog(responseString);
progressForUpload.progress = 0;

[ImagesCopy removeObjectAtIndex:0];
[tableview reloadData];

if (ImagesCopy.count == 0) {
    [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];

    [self.delegate didFinishController:self];
    }
}

- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
UIAlertView *erroragain = [[UIAlertView alloc]initWithTitle:@"Error" message:@"Something went wrong, this might be a server problem, log out and try again, if its still not working, wait a hour and try again" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[erroragain show];
 }

So this code runs fine, the video gets uploaded (if its under 20 seconds), now take a look at my php code:

<?php


$dbc = mysql_connect('hosting', 'user', 'pass');
if(!$dbc){
    die('not connected : ' . mysql_error());
}

$db_selected = mysql_select_db("db", $dbc);
if(!$db_selected){
        die("could not connect to DB : " . mysql_error());  
}

$username = $_GET['username'];

$check = mysql_query("SELECT video FROM members WHERE username='$username'");

$findMem = mysql_num_rows($check);

if($findMem > 0){
while($row = mysql_fetch_array($check) or die(mysql_error())){

$vid = $row['video'];

$vid = $vid + 1;

mysql_query("UPDATE members SET video='$vid'
WHERE username='$username'");

$uploaddir = './'.$username.'/default/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "done";


   }
   else{
       echo "error";
   }
}
}
?>

So i dont really get the problem, if it uploads videos under 20 seconds, it should be able to do longer right?

If someone could please help me figure out whats wrong with this, i need to be able to upload bigger videos, i have tried calling the sleep(5) in the php code to see if maybe the file just needed some time to process, didnt work.

Thanks,
Jacob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:30:26+00:00Added an answer on May 26, 2026 at 9:30 pm

    Sounds like you are hitting either the file upload size limit, the execution time limit, the memory limit, or disk space. You can change these in PHP.ini.

    Also, you are wide open to SQL injection, and you will be hacked if you don’t learn to do prepared queries with PDO, or at least escape your data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so heres my problem: I have an application I am working with that
Alright, so here's my problem. I'm trying to write a script in PHP that
Alright, currently I have my SWF hitting a php file that will go and
Alright, here is my problem i'm trying to solve. I have an index page
I have an input. I need to sanitize the input's string everytime the user
alright so i have a small problem here, i have this here. - (void)alertView:(UIAlertView
Alright, here goes. I'm making a very basic app, and I want the user
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright, so I'm working on a website and currently I have a shoutbox at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.