Solved

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

Posted on 2010-11-19
5
1,799 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
ID: 34171444
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
ID: 34178550
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
ID: 34178921
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
ID: 34187132
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
ID: 34221141
Got the ans after much seaching
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Making API calls from hashed passwords 26 54
Uncaught Type error cannot assign to read only property 6 27
jqury 17 30
How to create a textarea which saves text in HTML 8 37
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

773 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