HOW TO apply custom logic after uploading the file?

Discuss everything related to File Uploader. All versions. Any questions related to the File Uploader developing or using should be posted to this forum.

Moderators: alexandrleonenko, Milton

Milton
Senior
Senior
Posts: 31
Joined: Jan 14th, '10, 14:17

HOW TO apply custom logic after uploading the file?

Postby Milton » Nov 26th, '11, 20:22

If you want to apply some custom logic after uploading the file, you have to add your lines of code to inc/upload_result.php file after the move_uploaded_file line.

Code: Select all

// FIND THESE LINES
if(move_uploaded_file($file_tmp_name,'..'.$separator.$folder.$separator.$file_name))
{
           $statusText = "Success!";
           $status = "Success";
           // INSERT YOUR CODE HERE
           // SUPPOSE YOU WANT TO INSERT UPLOADED FILE'S NAME AND TYPE TO A DATABASE
           $mysql_host = "YOUR_HOST";
           $mysql_database = "YOUR_DATABASE";
           $mysql_user = "YOUR_USERNAME";
           $mysql_password = "YOUR_PASSWORD";
           $mysql_table = "YOUR_TABLE";
           $con = mysql_connect($mysql_host,$mysql_user,$mysql_password);
           if ($con)
           {
                mysql_select_db($mysql_database, $con);
                mysql_query("INSERT INTO ".$mysql_table." (name, details) VALUES ('".$file["name"]."', '".$file["type"]."')");
                mysql_close($con);
           }
}

Sardius
Master
Master
Posts: 135
Joined: Jul 3rd, '10, 18:45

Re: HOW TO apply custom logic after uploading the file

Postby Sardius » Apr 3rd, '12, 13:49

Can you explain how we can apply custom logic after deleting a file which has been uploaded successfully?

Milton
Senior
Senior
Posts: 31
Joined: Jan 14th, '10, 14:17

Re: HOW TO apply custom logic after uploading the file

Postby Milton » Apr 4th, '12, 18:09

Sardius wrote:Can you explain how we can apply custom logic after deleting a file which has been uploaded successfully?

I've created a new topic for this: viewtopic.php?f=67&t=3380&p=9693#p9693

vadims
Newbie
Newbie
Posts: 1
Joined: Jun 27th, '12, 07:31

Re: HOW TO apply custom logic after uploading the file

Postby vadims » Jun 27th, '12, 07:44

Hi

Did that, insert to db works but only the data of the first file are inserted. How can I fix that? I couldn't figure out what part of the code is loading with upload looping

Thanks

Milton
Senior
Senior
Posts: 31
Joined: Jan 14th, '10, 14:17

Re: HOW TO apply custom logic after uploading the file

Postby Milton » Jun 29th, '12, 19:13

Hello vadims

If you are using ApPHP AJAX File Uploader v2.1.2, you should replace this line

Code: Select all

mysql_query("INSERT INTO ".$mysql_table." (name, details) VALUES ('".$file["name"]."', '".$file["type"]."')");

with that one

Code: Select all

mysql_query("INSERT INTO ".$mysql_table." (name, details) VALUES ('".$files["name"][$i]."', '".$files["type"][$i]."')");


If that doesn't help please add this line

Code: Select all

alert(responseText);

to the beginning of the __uploader_showResponse function in the 'js/script.js' file and provide me the message which you'll see once a file is uploaded.


Return to “ApPHP AJAX File Uploader”