Solved

php file upload using http://valums.com/ajax-upload/

Posted on 2010-11-19
5
1,777 Views
Last Modified: 2012-05-10
Hi

I noted that quite a few in this forum recommend this site for file uploading.
I download this and wanted to know more on how to make modification.
My project is in php and mysql

First thing - using the demo from the client folder.
I can click on the browse button, select a file and it shows uploaded but I could not find the uploaded file.

Qns:
1) where is the file uploaded to?
2) how and where in the code should I modify if I want to upload the file to a specific folder?
3) where can I modify the code if I want to update a mysql table with the filename of the uploaded file upon successful uploading.
4) where can I modify the code if I want to trigger an ajax call once uploading is successful

I dont seems to be able to find a full working sample (with codes) and explanation.
Hope someone can offer me a sample code with the above qns.

Thanks.
0
Comment
Question by:LimMH
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:CyberGhost
Comment Utility
uploaded files are being stored in a temporary folder, from where you can move them anywhere you need and perform additional tasks as well... for more information, see:

http://php.net/manual/en/function.move-uploaded-file.php
http://www.php.net/manual/en/features.file-upload.php
0
 

Author Comment

by:LimMH
Comment Utility
Hi,

thank you for the comment. I know of moving the file via php function. But I do not know where is the uploaded file located for me to be moving that file to the specific folder I wanted.

I noted in the php.ini that it says temp upload folder to be c:\windows\temp folder but I could not find the uploaded file in that folder.

Thus I am unsure if the file is actually uploaded bec maybe the demo.html script in http://valums.com/ajax-upload/ is not complete (ie it show the proccess of uploading but it doesn't really upload a file??)
Thus asking for user with experienced using http://valums.com/ajax-upload/ for assistance and more info.

Thanks
0
 
LVL 6

Accepted Solution

by:
CyberGhost earned 500 total points
Comment Utility
according to the manual, your "upload_tmp_dir" setting determines where your files are being uploaded to... if that folder does not exist or is not writable, PHP will use system default (could be C:\Windows\temp)

when a file is uploaded, it does not have the same name as the original - it is renamed to a temporary name, which can be retrieved using $_FILES['userfile']['tmp_name']

your original name is still being stored in $_FILES['userfile']['name']
0
 

Assisted Solution

by:LimMH
LimMH earned 0 total points
Comment Utility
ok I found out how to do it
Both client folder and server folder has to be used bec the php file to move the uploaded file is in the server folder. Alternatively I can copy the php.php file and the uploads folder and paste them into the client folder.

ANS to Qns 1:
============
In the demo.htm page, change:

from

action: 'do-nothing.htm,

to

action: '../server/php.php',
[or if did the copying, use action: 'php.php',]

So when uploading, the uploaded file will be inside the server/uploads folder [or client/uploads folder - if did the copying].


ANS to Qns 2:
============
make changes to the server/php,php file.
on the 160 line, it upload to the specific folder
$result = $uploader->handleUpload('uploads/');

ANS to Qns 3:
============
I can write the mysql code in the php.php file

ANS to Qns 4:
============
I can call an ajax function in the demo.htm file. I can add an event for:

onComplete: function(file, response) { myajaxevent();}

Hope this will prove useful to someone else.

0
 

Author Closing Comment

by:LimMH
Comment Utility
Got the ans after much seaching
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now