robert_gsfame Posted December 2, 2009 Share Posted December 2, 2009 I used to do upload file and now i'm trying to download the file from the upload folder...can anyone tell me how to do it. Let say i have folder called "upload" and there is an image called "image.jpg" then how to create a link to download the image.jpg <a href="upload/image.jpg">Download file</a> This is wrong!, can anyone help me Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/ Share on other sites More sharing options...
mikesta707 Posted December 2, 2009 Share Posted December 2, 2009 Im not sure of your question. Are you asking how to prompt the user to download the file on a link click (IE a forced download?) Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969514 Share on other sites More sharing options...
robert_gsfame Posted December 2, 2009 Author Share Posted December 2, 2009 i want to download a file that is stored inside my upload folder i try this but it didn't work as file always in txt <?php header("Content-Disposition: attachment; filename='image.jpg'"); header("Content-length: 10000"); header("Content-type: jpg");?> which part is wrong?? Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969517 Share on other sites More sharing options...
mikesta707 Posted December 2, 2009 Share Posted December 2, 2009 Content-type has to be a valid mime-type. http://www.w3schools.com/media/media_mimeref.asp that has a list of mime types for the different file types Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969519 Share on other sites More sharing options...
robert_gsfame Posted December 2, 2009 Author Share Posted December 2, 2009 that's already valid mikesta, what's wrong with 'image/jpeg'?? Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969521 Share on other sites More sharing options...
mikesta707 Posted December 2, 2009 Share Posted December 2, 2009 the code you posted only says : jpg not image/jpg Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969528 Share on other sites More sharing options...
robert_gsfame Posted December 2, 2009 Author Share Posted December 2, 2009 sorry wrong post, okay i can download it now in correct format, but then i cannot open it file:///C:/DOCUME~1/WINDOW~1/LOCALS~1 was typed on url can fix this? how to change the path?? Quote Link to comment https://forums.phpfreaks.com/topic/183684-download-file/#findComment-969531 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.