473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Can't read read uploaded file in FTP server.

Exequiel
288 256MB
Hello guys, I have a simple code for uploading a file in an ftp server, it works properly, but Im wondering why doese every time i open or trying to view the uploaded file in the ftp server its looks blank, heres my code
Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['ok']))
  2. {
  3.   $ftp      = $host;
  4.   $username = $usr;
  5.   $pwd      = $pwd;
  6.   $filename = $_FILES['file']['name'];
  7.   $tmp      = $_FILES['file']['tmp_name'];
  8.   $d        = 'CCTV';
  9.  
  10.   $connect = ftp_connect($ftp)or die("Unable to connect to host");
  11.   ftp_login($connect,$username,$pwd)or die("Authorization Failed");
  12.   echo "Connected!<br/>"; 
  13.  
  14.   if(!$filename)
  15.   {
  16.     echo"Please select a file";
  17.   }
  18.   else
  19.   {
  20.     ftp_put($connect,$d.'/'.$filename,$tmp,FTP_ASCII) or die("Unable to upload");
  21.     echo"File successfully uploaded to FTP";
  22.   }
  23. }
Expand|Select|Wrap|Line Numbers
  1. <form action="" method="post" enctype="multipart/form-data">
  2. <input type="file" name="file" /><br/>
  3. <br/><input type="submit" name="ok" value="Upload" /></form>
I tried to use ch mod but its not working
I attached the image of result, I hope someone help me here, thank you so much. :)
Attached Images
File Type: jpg 1.jpg (35.6 KB, 130 views)
File Type: jpg 2.JPG (17.0 KB, 143 views)
Sep 30 '16 #1

✓ answered by Oralloy

Exequiel,

Obviously you found the file, so at least one upload was successful.

Just a few quick questions:
  1. The file is small, what were you expecting to see, when you looked at it?
  2. When you upload a text file, instead of a JPG, can you see the correct contents?
  3. Is the web page after up-load showing success?
  4. Is the file size truly zero when you look at the file after upload?
  5. Does the file size exactly match on the client and server?
  6. If need be, can you check the file size from the explorer or the command line on the server?
  7. If the file sizes do not match, then you probably have a data conversion problem.
  8. Is your upload call (ftp_put) implicitly binary? (I am not a PHP ace, so you have to check this).
  9. Is there a way to make the upload explicit binary? (this is to remove all chance of stupid).
  10. When you run an upload test, is the file actually replaced (the time-stamp and file-size should change)?

Luck!
Oralloy

4 1247
Oralloy
988 Expert 512MB
Exequiel,

Obviously you found the file, so at least one upload was successful.

Just a few quick questions:
  1. The file is small, what were you expecting to see, when you looked at it?
  2. When you upload a text file, instead of a JPG, can you see the correct contents?
  3. Is the web page after up-load showing success?
  4. Is the file size truly zero when you look at the file after upload?
  5. Does the file size exactly match on the client and server?
  6. If need be, can you check the file size from the explorer or the command line on the server?
  7. If the file sizes do not match, then you probably have a data conversion problem.
  8. Is your upload call (ftp_put) implicitly binary? (I am not a PHP ace, so you have to check this).
  9. Is there a way to make the upload explicit binary? (this is to remove all chance of stupid).
  10. When you run an upload test, is the file actually replaced (the time-stamp and file-size should change)?

Luck!
Oralloy
Oct 3 '16 #2
Exequiel
288 256MB
wow, thank you so much for the comment Oralloy this a big guide for me, I check mostly of your comments already, it seems that the files the i uploaded is not same size to the original file in local, for example the image file that i want to upload has a size of 800kb, when uploaded to ftp the size of the image become smaller like 9b, i guise the file is not fully uploaded, but in my system i made, it indicates file successfully uploaded, I tried to use filezila theres no problem here when uploading files, only in my code, it seems i need to add something, but i dont know what is it, i tried to chmod the folder in ftp using terminal in linux but it cannot chmod, i tried to use ftp_chmod function in php still did not work damn, haha, thank you so much for the reply, i really appreciate, :) T.T
Oct 3 '16 #3
Oralloy
988 Expert 512MB
Exequiel,

You're quite welcome.

If you're doing an ASCII transfer of an image file, then you are probably doomed. In the ASCII transfer, CR/LF is often mapped into LF, or the other way around. This is to allow text files to be immediately useful after transfer.

Good luck. I'll check in again tomorrow.

Oralloy
Oct 3 '16 #4
Exequiel
288 256MB
problem solved Oralloy, thank you so much for the help. I can now upload to ftp server fully, till next time. :)
Oct 3 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Don | last post by:
Hi all, I need to read an uploaded file into chunks, so I can examine the acculative size between chunks to determine if a maximum size is being exceeded. I'm currently using the PHP function...
1
by: Oyvind Ostlund | last post by:
I am trying to read a file online, and was just testing a bit. This is what I tried. -------------------------------------- import sys, httplib showlines = 6 try: servername, filename =...
1
by: Jason | last post by:
Hi, Does anyone know how I can connect to an MSDE db using VB with a read-only file? The file will be on a CD, and is actually just archived data off a SQL server. I would like to package my app...
5
by: Martin Svensson | last post by:
Hello! I need some help/recommendations on how to do the following. I have a program that writes an IP address two control numbers and a date to file, on one line. It's a basic text file and it...
5
by: ashton | last post by:
Hello, I have a file (mytest.fle) it is just a text file with a different extension. I would like to be able to open this file through my C++ application and read it in as a string. For...
8
by: noleander | last post by:
I've got two threads reading from one disk file (I'm using the Pthread library). I need each thread to have its own file seek pointer, so they can read from independent parts of the file. I...
4
by: Michael | last post by:
I am trying to open a file on the client machine from an aspx page running server side. The design requirements of the page specify that the HtmlInputFile control is not to be used. Since the...
9
by: John Howard | last post by:
How can I read a text file that is on a UNIX server in VB.Net? Please keep it simple. Thanks, John
5
by: Nick Z. | last post by:
When using SmtpClient and sending a message with an attached file using SendAsync(...), if I add File.Delete(pathToAttachedFile) in the SendCompleted event handler I get a file in use exception. Is...
8
by: Vijay | last post by:
Hi , I am doing a small project in c. I have a Hexadecimal file and want to convert into ascii value. (i.e., Hexadecimal to Ascii conversion from a file). Could anyone help me? Thanks in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.