[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2010-11-19
5
Medium Priority
?
1,866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 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