i can easily upload excel if i used simple
<input type="file" name ="file">
this function simple browse the file and using simple php code excel data is saved in the data base. I need to upload excel file in some directory on time bases by cron job . i know very well cron job but. i am unable to do without input type file there is any way to upload file with using file type.
Pl z suggest me if any solution for that i waiting.
Thanks and regards
You can use wget or curl, see this thread on Superuser for examples:
https://superuser.com/questions/86043/linux-command-line-tool-for-uploading-files-over-http-as-multipart-form-data
The rename function does this (delete old file)
rename('text.xls', 'folder_2/text.xls');
PHP RENAME DOC
if you want to keep old file
The copy function
copy('text.xls', 'folder_2/text.xls');
PHP COPY DOC
Related
I have been installed the git lib from https://github.com/Azure/azure-storage-php .
I able to figure out the create file, download file, delete file.
But how can get the file content of the file and display on browser ?
Thank you.
I'm not that much knowledgeable about PHP but I believe the SDK method you would want to use is getBlob which reads a blob and returns an object of type GetBlobResult.
Contents of the blob can be read using getContentStream() method there.
If you're using Azure Files, more or less the approach would remain the same. You would be calling getFile method which reads a file and returns an object of type GetFileResult.
Contents of the file can be read using getContentStream() method there.
I want to create file sharing platform but php has some bug about it.I just use fread to get text of any file (exe,pdf,docx,ppt and etc) then I create text file with random name and with .txt extension.So when user want to download this file ,I create random folder and inside of that folder I create file which has same text that user want to download , and then I give extension which is same as user uploaded version of file and force user to download it.
But when user download file,for example zip file and then if user wants to open , it says failed to open because not supported format.This happens when I try to do this with docx,pdfs,zips and that kind of files (not txt,html,css,c files).
Example : I force the user to download with same extension that he uploaded, for example if user uploaded zip file,I read the text with fread then save this text in the db or text file,and then if user wants to download that file, I just create file and give it zip extension, then force the user to download it,but once user upload this file then if user want to open it fails, but it should open zip file because content text of this file is exact same as user uploaded to the server
Answer should contain:
1)Why this happens?How to fix it?
2)What is the ideal solution?
3)is it safe to do this?
This happens, because windows knows the app to open file file just from the extension. If you rename the file to something.txt, then the editor always wants to open it.
There's no such thing as an ideal solution. A soltution would be to store the file with the original name (maybe at some unique part to prevent duplicates) in a non public readable directory without execution bit set. To access the file, you could create a proxy script, which returns the file and appens a should download header (and maybe the original filename).
Its as safe, as you implement it. Your current solution could be safe, the solution I posted could be safe - but without knowing the details, how you implemented it, nobody knows, if it is actually safe.
It happens because you are opening binary files like a zip file and storing it in a text file then streaming it with the zip extension again.
The ideal solution would be to use one of the 1 million open source file managers out there with proven records and big developer communities. But if for some reason you want to build your own, save the files in a safe folder outside your public folder. store the path in a database of choice together with the public path you will show your users. Upon request use the public path to map to the private path and start the download yourself.
Is as safe as you make it, but nothing is 100% safe so if you are storing sensitive data use something that is well build and documented
i'm looking for a simple way to download remote images to my sever, rename and save image name to database.
I know how to download the file easily to my sever
copy('http://example.com/file.jpeg', '/tmp/file.jpeg');
But how to i rename the image while downloading or after download?
I would really appropriate if anyone can tell me a simple way to do this using php
In copy function just change file name:
copy('http://example.com/file.jpeg', '/tmp/any_file_name.jpeg');
I think this should do the Job
rename("/tmp/tmp_file.jpg", "/home/user/login/docs/my_file.jpg");
you have to do this after you downloaded it
or just change the file name while you dwonload it e.g.
copy('http://example.com/file.jpeg', '/tmp/some_name.jpg');
I'm trying to set up a file upload for my website but I'm not sure what I'd need to get this to work overall. I'm trying to use Jquery File Upload but I can't seem to get the files to upload to my server. It looks like I might need something else to get it to run but I'm not sure what. Any suggestions?
There are three "sides" to a file upload.
First is client-side: You need to have a form that can upload files (so you need to set the enctype attribute of your form element, and set your action to post).
Second is server-side: You need something that can handle the file upload. Assuming you're using a server with PHP, you can access the file via $_FILES['filename']. Google has a vast array of example for handling file uploads.
Third is server-side (again) - your server must allow file uploads. Not only must it allow file uploads, but it restricts the size of the file that can be uploaded (php config).
However, it looks like jquery file upload has a PHP file handler.
I will sugest you use dreamweaver its easy to use expecially to upload files to the web n you can also see the steps needed in its help content. or you may download an ftp uploader
I am using https://github.com/Widen/fine-uploader uploader script on my website. I am searching for solution to save uploaded file in qq file uploader using php server side script.
I tried to request file using $_FILES['qqfile']['tmp_name'] but didn't works. Can anyone tell me php example to request and save file in qq file uploader?
Have a look at the php example in the server folder of the file-upload github project.
goto this url
http://code.google.com/p/php-axiom/source/browse/trunk/libraries/uploader/qqUploadedFileXhr.class.php?spec=svn41&r=41
or search about qqUploadedFileXhr
Incase of those who may bump into this thread, here's a perfect example, helped me alot
http://wsnippets.com/fancy-profile-image-upload-crop-jquery-ajax-php/