Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-11-19
5
Medium Priority
?
1,881 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

571 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